in
Welcome to Lionhead Community Sign in to Windows Live ID | Help

Ok, I'm trying to learn to program, why doesn't this work:

Last post 01-07-2007, 2:31 by Rectov. 1 replies.
Sort Posts: Previous Next
  •  01-07-2007, 2:31 2435680

    Ok, I'm trying to learn to program, why doesn't this work:

    In my c:\projects\src\test folder, I have this program: [code] package test; class Test { public static void main(String[] args) { System.out.println("Hello!"); } } [/code] I compile it (from the src folder) with: javac -d bin -sourcepath src src\test\Test.java It compiles without error. Then when I try to run it with: java bin\test\Test I get: Exception in thread "main" java.lang.NoClassDefFoundError: bin\test\Test (wrong name: test/Test) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) 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 Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) I only get this error when the name of the target file is correct... otherwise I just get... Exception in thread "main" java.lang.NoClassDefFoundError: Test Any answers?
  •  01-07-2007, 3:19 2435718 in reply to 2435680

    Re: Ok, I'm trying to learn to program, why doesn't this work:

    Well Rectov, you do it like this: projects>java -classpath bin test.Test Thanks Rectov. You're welcome Rectov. I've seen the error of my ways: It was thinking there was some kind of error in my ways and wanting to go away and better myself before acting on impulse.
View as RSS news feed in XML