Computing.Net > Forums > Linux > programming java problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

programming java problem

Reply to Message Icon

Name: billygao
Date: October 24, 2004 at 13:02:35 Pacific
OS: Linux 10
CPU/Ram: AMD
Comment:

I installed the java jdk1.5 in my linux system, but tried a sample code 'hello world', found that it doesn't work. Somebody please help.

CODE:
import java.lang.*;
public class HelloWorld
{
public static void main(String args[])
{
String str = new String("hello world");
System.out.println(str);
}
}

EXCEPTION MESSAGE:
[]#java HelloWorld.java
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/java

I don't understand why it's 'HelloWorld/java',
instead of 'HelloWorld.java'



Sponsored Link
Ads by Google

Response Number 1
Name: 3Dave
Date: October 27, 2004 at 04:52:01 Pacific
Reply:

Try this:
$ javac HelloWorld.java
This should create a HelloWorld.class, then
$ java HelloWorld
NB HelloWorld.java and HelloWorld.class should both be in the same directory or dump HelloWorld.class into your classpath.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: programming java problem

Strange Java Problem www.computing.net/answers/linux/strange-java-problem/23380.html

java problems www.computing.net/answers/linux/java-problems/23443.html

Gtk+/gnome programming install problems www.computing.net/answers/linux/gtkgnome-programming-install-problems/1254.html