File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Problem with Hello World Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with Hello World" Watch "Problem with Hello World" New topic
Author

Problem with Hello World

Terry Wynn
Greenhorn

Joined: Dec 18, 2009
Posts: 17
Just getting started. I got the following:

C:\Jplan>javac hello.java

C:\Jplan>java hello.java
Exception in thread "main" java.lang.NoClassDefFoundError: hello/java
Caused by: java.lang.ClassNotFoundException: hello.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
Could not find the main class: hello.java. Program will exit.


So I can compile, but not execute.

The startup at the Cattle Drive indicates that I need to set my CLASSPATH to

.;C\Jplan

I believe I have.

Although I don't know how to check that.

Thanks in advance for the help.


Program is


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


located in c:\Jplan\hello.java


W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Rather than running it with:

C:\Jplan>java hello.java

Use:

C:\Jplan>java hello


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Terry Wynn
Greenhorn

Joined: Dec 18, 2009
Posts: 17
Whoopsie.

Thank you very much. Works fine.


Sorry to be THIS stupid. I am sure none of you did anything like this in the beginning.
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Terry Wynn wrote:Whoopsie.

Thank you very much. Works fine.


Sorry to be THIS stupid. I am sure none of you did anything like this in the beginning.


To be honest, I've been studying Java for about a year now and I STILL do that sometimes. I will stare at the command line for about 5 seconds wondering what happened, then proceed to laugh at myself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Hello World
 
Similar Threads
UnsupportedClassVersionError, help
running java program out of workspace
java stopped working
Please Help !!! (package and accessibility)
Package question