• Post Reply Bookmark Topic Watch Topic
  • New Topic

installing java  RSS feed

 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a JRE 1.4.2 that I'm trying to get to work. It may be some special distribution because it comes with javac.exe. So, I guess that I can compile programs, like this one:

public class Test {
public static void main(String[] args) {
for(int i=0;i<10;i++) System.out.println("This is the number i=" + i);
}
}

When I run "javac Test.java", I don't get any errors, but when I try to run "java Test", I get an error that says:

Exception in thread "main" java.lang.NoClassDefFoundError: Test

What is happening?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
means java cant find your Test.class file.

This might help you
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah...just needed to put the current directory into the classpath. Thanks!
 
Paulo Lima
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Christopher.

Check if you are at same directory that this class file (Test.class)

If yes, try to run this command:

java -cp . Test

this work even your environment has a CLASSPATH variable configured to another path.

Regards,

Paulo Lima.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!