File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot get simple java file to run" Watch "Cannot get simple java file to run" New topic

Cannot get simple java file to run

Hui Ge

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

package tryout;

class Test {
public static void main(String[]args) {

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/
java tryout.Test
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Try making the Test class public.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Cannot get simple java file to run
jQuery in Action, 3rd edition