This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Cannot get simple java file to run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot get simple java file to run" Watch "Cannot get simple java file to run" New topic
Author

Cannot get simple java file to run

Hui Ge
Greenhorn

Joined: Mar 11, 2005
Posts: 25
i created Test.java in directory tryout:

package tryout;

class Test {
public static void main(String[]args) {
System.out.println("testing...");
}
}

compiled and run the file "java Test" and got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: tryout/Test)

What could be wrong?
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Try ..
javac tryout/Test.java
java tryout.Test
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Try making the Test class public.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Cannot get simple java file to run