Results 1 to 4 of 4
- 10-13-2011, 07:14 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 4
- Rep Power
- 0
Newbie question about basic code - "Hello World"
I'm working through Java Examples in a Nushell and the first example includes syntax that I would like to understand better. Really basic;
package je3.basics;
public class Hello {
public static void main (String [] args) {
System.out.println ("Hello World");
}
}
It compiles but it generates exceptions. I get this error;
c:\JFiles\Java Examples in a Nutshell\Chapter 1>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello (wrong name: je
3/basics/Hello)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(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 sun.launcher.LauncherHelper.checkAndLoadMain(Unkno wn Source)
I know enough about this that if I remove the package syntax that it will work fine, but the book makes the point that adding prefixes in the long run is a good idea since it helps avoid naming conflicts. Cool. Why doesn't it run?
- 10-13-2011, 07:47 PM #2
Re: Newbie question about basic code - "Hello World"
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 10-13-2011, 07:48 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 4
- Rep Power
- 0
Re: Newbie question about basic code - "Hello World"
Thanks, Kevin. I figured it out but couldn't post until now (the forums have been running slow this morning, I think.) Thank you for the reply.
- 10-13-2011, 07:56 PM #4
Re: Newbie question about basic code - "Hello World"
No problem. The forums have been slow for me as well.
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
Similar Threads
-
[newbie] Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
By Bmorebob in forum JCreatorReplies: 6Last Post: 03-19-2011, 08:10 PM -
how to write a program for " world cup " in java
By sus in forum New To JavaReplies: 24Last Post: 06-21-2010, 05:49 PM -
[newbie] Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException:
By jon80 in forum New To JavaReplies: 3Last Post: 06-07-2009, 01:14 AM -
String greeting = "Hello, world!";
By Gregorius in forum IntroductionsReplies: 2Last Post: 01-24-2009, 02:12 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 08:35 AM
Bookmarks