This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman 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 Building Microservices this week in the Design 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: 17271
    
    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
 
Consider Paul's rocket mass heater.
 
subject: Cannot get simple java file to run
 
It's not a secret anymore!