Error while trying to run program using java.exe

First of all I'd like to apoligize if this thread already exists here somewhere.. I've spent the last hours Googling and searching the forums for an answer, but haven't found one, so I posted a topic..

The problem is the following:

I'm using Netbeans 5.5 with JDK1.6.0. When I build/run a Java application in this IDE, I get no errors whatsoever..

But, when I try to run it from the prompt, using following code (I copied the .class file into the same directory as the .java file)

java -classpath . main.java

I get the following errors:

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Sour

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$000(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Metho

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

I'm quite sure that the problem is something I'm simply missing, since Netbeans runs everything without troubles..

Anyone an idea how I could solve this problem? (Trust me, I checked the net, lots of people with this prob, but no decent solutions given)

Thanks in advance (and once again sorry if this thread already existed).

Greetings,

Tribio

[1691 byte] By [Tribioa] at [2007-11-26 15:13:02]
# 1
I hope that was a typo in your posting, but you shouldn't include the .java extension when running java...java -classpath . main
Peetzorea at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 2
> I hope that was a typo in your posting, but you> shouldn't include the .java extension when running> java...Was a typo, sorry.. But you made me curious, so I tried it with and without the .java added, and both gave the same errors..
Tribioa at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 3
What exception do you get before the "at ... "? Is your class main in the default package or did you put it in a package? If it is you should include the package name.. (please tell me if I'm looking at it too simple...)
Peetzorea at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 4

Oh, forgot the first error line indeed, thanks for pointing that out.

D:\Tribio\JPF\src\jpf>java -cp . main

Exception in thread "main" java.lan.NoClassDefFoundError: main (wrong name: jpf/Main)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Sour

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$000(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Metho

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

And concerning the package question. In the code of main.java I define the package jpf as follows:

package jpf;

Hateful problem, and I so wanna use the prompt java once in a while instead of having to rely on NetBeans..

And you're not at all looking at it too simple, any input on the matter is appreciated.. :)

Tribioa at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 5
try going to the directory above your .class file (it should have a directory jpf. Then run the command java -cp . jpf.Main The capital M is quite important...
Peetzorea at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 6
Yippie, that fixed it! Thanks a lot!*overloads you with dukes*
Tribioa at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...
# 7
You're welcome!
Peetzorea at 2007-7-8 9:04:12 > top of Java-index,Java Essentials,New To Java...