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 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 17249
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cannot get simple java file to run
 
Similar Threads
Java file name
Getting error while running java program
How to connect Driver
Exception in thread "main"
Calling 'dig' program in a java program