command line java tools??

kermit64

Registered
i can't get a simple class to run on the command line. here's the class
//the file's name is a.java
public class a
{
public static void main(String a[])
{ System.out.println("Hello World!"); }
}

then, in the same directory as that file, i type:

javac a.java
java a.class

then, it spits me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: a/class

i'm pretty sure i've done this before so it's probably something really stupid that i don't understand but i need help.
 
Hey Kermit,

Try:

<b>"javac a.java"</b>

then

"<b>java a"</b> (without the .class)

You're not supposed to use "*.class" when you run it throgh java..

That ought to do the trick..

If you run into more problems try renaming the class to something a little longer and more descriptive.. Not sure it'll like a short classname like "a".

X is perfect for Java development.

Good luck!
 
That is one of the MOST COMMON mistakes people do when starting out with java.. I have done that numerous times.. :D
 
Two other mistakes I can think of, off the top of my head:

-- use Unix line breaks \n instead of \r (very important for perl, if not java)

-- inner classes are referenced with a dollar sign ($). So if you have a class BigClass.SmallClass, then the name is represented as BigClass$SmallClass.

Any other odd stumbling blocks to be aware of?

[Edit

-- to set the classpath in ProjectBuilder, go to the build settings frame, then under one of the tabs there is an advanced option which shows the classpath setting]
 
Back
Top