• Post Reply Bookmark Topic Watch Topic
  • New Topic

just getting started. can compile, won't run  RSS feed

 
Dr. James Stankus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class MyFirstApp {

public static void main (String[] args) {
System.out.println("I Rule!");
System.out.println("The World");
}
}

compiles fine, no errors.
when I type "java MyFirstApp", I get the following:

Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp

using WinXP. I've set my PATH variable to include "C:\Program Files\Java\jdk1.5.0_06\bin"

Any ideas?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. A title and a surname isn't enough. You can change your display name here. Thanks!

Now, as to your question: you -- like most beginners to Java -- have listened to some bad advice and also set your CLASSPATH variable to something or other. Unset it. Go to your control panel and just completely remove CLASSPATH (not PATH, which is fine -- CLASSPATH). When you open a new terminal window, you will find that your command will work.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dr. Stankus,

Welcome to the Javaranch!!! First, a little business. You seem to have missed our Naming Policy on the way in. Basically, we require a real sounding first AND last name. Obviously ficticious names are also not allowed. Please go here and update your profile.

Once you've done that, your much more likely to get some help.

See you 'round the Ranch.
 
Dr. James Stankus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Hi,

Welcome to JavaRanch!

First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. A title and a surname isn't enough. You can change your display name here. Thanks!

Now, as to your question: you -- like most beginners to Java -- have listened to some bad advice and also set your CLASSPATH variable to something or other. Unset it. Go to your control panel and just completely remove CLASSPATH (not PATH, which is fine -- CLASSPATH). When you open a new terminal window, you will find that your command will work.


I wonder if it set the CLASSPATH itself at install? I didn't do it.

Deleted and working, thanks!
[ April 27, 2006: Message edited by: Dr. James Stankus ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!