• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about compiling

 
Scott Mahoney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, hello to everyone. This is my first post on here. I'm new to Java programming, but not a complete noob when it comes to other languages.

I'm having problems compiling anything in Java. I followed the HelloWorld tutorial found at (http://www.javaranch.com/java-college.jsp)--added the PATH, CLASSPATH, etc.--but it doesn't seem to be working.

Here's the code I entered into my editor:

public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}


Then I went to the command prompt and entered:

javac HelloWorld.java

After that I typed in:

java HelloWorld.class

I get the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class

Any help that you can offer would be greatly appreciated.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

When executing Java programs using the "java" executable you do not specify the file name, but the class name. So instead of "java HelloWorld.class" it should be "java HelloWorld".
 
Scott Mahoney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf. That worked, and now I feel like a complete noob
 
Campbell Ritchie
Sheriff
Pie
Posts: 49845
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Mahoney:
Thanks Ulf. That worked, and now I feel like a complete noob
yes, Ulf is very helpful. But don't feel bad about it; everybody does the same thing!
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody was a noob at one time. After a year, I still am. Thank goodness for the JavaRanch.com where people help you when you're stumped.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic