File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
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 ( 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:


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: 42959
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

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: 45287
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 where people help you when you're stumped.
I agree. Here's the link:
subject: Question about compiling
It's not a secret anymore!