java

Direct flow depending on incoming dynamic type

I have a listener class that accepts GUI change events in one method. The incoming event objects have a superclass of a type of GUI Event, the behaviour should depend on the dynamic type of the incoming variable. I wanted to do do lots of methods like: handleGUIEvent(EventChangedX event) handleGUIEvent(EventChangedY event) I am usin...

Questions about IntelliJ to Eclipse transition

I just started using eclipse for some personal projects and am finding the transition from IntelliJ (what I use at work) kind of annoying. I hope it's kosher to ask a few different questions in the same thread. Here goes: 1) How do I get "views" (I'm not sure if this is the term. I mean windows such as Project Explorer, Servers, Console...

Netbeans "Build" vs. "Source" resource problem

The text for my buttons is being saved by default as a resource. But then when I click "run," the resource file it loads is the one in the "build" part of the project, not the "source" part. And they aren't the same! For instance, one button I call "create chart". If I do "Clean and Build" it loads correctly, but after that, any changes...

Secure iNet Factory and Apache httpclient, which one is more powerful?

Hi, I'm new to both of the two libraries. Now I need a java http library in my application. My question is which of the two is more powerful? Thanks. PS: Secure iNet Factory: http://www.jscape.com/secureinetfactory/index.html ...

How to set JFace ListViewer size?

OK - I give up. How can I set width and height of a JFace ListViewer? This should be self-evident but can't seem to find anything and there's no obvious way of doing it looking at the methods of the class. Tried this with no luck: myListViewer.getControl().setSize(1000, 1000); Any help appreciated. ...

How to load files into session bean

Hi all, I have a java EE application EE5 EJB3. I develop using NetBeans 6.7 and GlassFish 2.x I need to have a configuration file (*.xsl, *.xml) that is deployment/client specific. My questions are: 1) where do I put files that are external to the ear file? 2) How do I load the files into a session bean? can I use injection? I mana...

Wrong Time with System.currentTimeMillis () (Java)

Hi, I made a little program to test the System.currentTimeMillis (). And I have a strange result. This is my logs : 1 26-12-09 20:48:21 - [Log] lTime = 1261860501009 2 26-12-09 20:48:21 - [Log] lTime = 1261860501012 3 26-12-09 20:48:21 - [Log] lTime = 1261864899078 4 26-12-09 20:48:21 - [Log] lTime = 1261860501033 5 26-1...

Java Export - Text Files

I tried to export a Java program from Eclipse to a .jar file, but I came across a problem. It ran fine, but for some reason it didn't find the text files it was supposed to get data from. If anyone could help with this, I would be very grateful. ...

XML Structure creations issue

I data in the below format (List of HashMap's) {TeamName=India, Name=Sachin, Score=170} {TeamName=India, Name=Sehwag, Score=120} {TeamName=Sri-Lanka, Name=Sangakara, Score=20} {TeamName=Sri-Lanka, Name=Murali, Score=20} {TeamName=Sri-Lanka, Name=Jayasurya, Score=70} Below is the desired output <node id="1" label="India" > <no...

Deeply Nested Inheritance - Bad or Good Practice?

I am in the process of making a PHP web application. I have a situation that I believe would foster a good time for nested inheritance. Anyway, here is my situation: public class RecurringWeeklyEvent extends RecurringEvent { } public class RecurringEvent extends Event { } It does not seem to me that this would be a bad design practic...

I-Phone VM for Android

I'm considering opening up a project to create an i-phone virtual machine for android 2.0 (read motorola droid) before i do so i have some questions: Does one already exist that i just missed? Can the the Droid's Arm Cortex A8 down-clocked to 550MHz (thanks wikipedia) handle an I-Phone abstraction layer? Performance wise the best thing...

False errors in eclipse?

Okay, so eclipse says my code has errors in it, but there are no red lines. When I try to run my project (Called Game2) it gives me this error: java.lang.NoClassDefFoundError: Game2 Caused by: java.lang.ClassNotFoundException: Game2 at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(N...

Java: Illegal Argument Exception

I'm getting an IllegalArgumentException, but I can't figure out why. The function I'm trying to access: private static Player checkEvents(Player[] players, GameMaster bananas) The problematic code: @Test public void testCheckEvents() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, I...

Start Android Market from App

I'm developing a lite version for an app on the Android. How can I start an Intent to open the Android Market, preferably with the full version of my app displayed? This is difficult to test on an emulator (which is the closest thing to a device I have), as there seems to be no legal way of installing the Market on it. ...

spring hibernate configuration using resource_local or jta by default?

may i know as my configuration is done directly on applicationContext.xml, i do not have persistence.xml . by default this is resource_loca or jta? do i need to add extra parameter if i want to use jta? <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"...

Pass a command line argument to JAR in an Ant script

I've got a executable JAR file. And I've got an Ant build script that compiles and then creates this JAR file. I would like a task to run the JAR file as well, but I've got a command line argument that needs to be passed to the JAR. It's a configuration file. The run target is below <target name="run"> <java jar="build/jar/ShoutGen....

Why does language verbosity have a negative connotation?

I hear people comment on Java's verbosity (and other languages) as if it were a bad thing, why? To me it makes code easier to understand. Less typing seems like a really trivial argument. ...

How to write Java-like enums in C++ ?

Coming from Java background, I find C++'s enums very lame. I wanted to know how to write Java-like enums (the ones in which the enum values are objects, and can have attributes and methods) in C++. As an example, translate the following Java code (a part of it, sufficient to demonstrate the technique) to C++ : public enum Planet { ...

C to Java port: calculating a 3 byte checksum

Does this seem correct? I'm trying to port this checksum method from C to Java but the values returned from my Java function are too high. I suspect the way I'm fudging the unsigned int is not correct? char *Generate( char * buffer, long length ) { static char tBuf[4]; long index; unsigned int checksum; for( index ...

How do I intialize a Graphics object in Java?

this is the code: import java.awt.*; import java.applet.*; public class anim1 extends Applet{ public void paint (Graphics g) { g.drawString("",400,300); } public static void main(String ad[]) { anim1 a=new anim1(); Graphics g1; a.paint(g1); } } It says that g1 is not initializ...