This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about compiling" Watch "Question about compiling" New topic
Author

Question about compiling

Scott Mahoney
Greenhorn

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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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

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

Joined: Oct 13, 2005
Posts: 44520
    
  34
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: 689

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about compiling
 
It's not a secret anymore!