• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot get simple java file to run

 
Hui Ge
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try ..
javac tryout/Test.java
java tryout.Test
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making the Test class public.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic