wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Question about compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about compiling" Watch "Question about compiling" New topic

Question about compiling

Scott Mahoney

Joined: Jan 10, 2008
Posts: 3
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

Joined: Mar 22, 2005
Posts: 41112
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".

Ping & DNS - my free Android networking tools app
Scott Mahoney

Joined: Jan 10, 2008
Posts: 3
Thanks Ulf. That worked, and now I feel like a complete noob
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38008
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

Joined: Nov 18, 2006
Posts: 688

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.
Don't get me started about those stupid light bulbs.
subject: Question about compiling
Similar Threads
Simple Person Program
Java Projects
Programming Asignments
Java Project
Learning suggestions