• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with something Simple

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code and its supposed to write a batch file and basically pings everything between snap0000 and snap 9999.

import java.io.*;
public class CheckForSnap
{
public static void main( String[] args)
{
try{
BufferedWriter out = new BufferedWriter(new FileWriter("checkForsnap.bat"));
for(int n = 0000;n<10000;n++){
out.write("ping snap" + n);
out.close();
}

}catch (IOException e){
}



}
}

and it gives this error when ran, it compiles fine.

Exception in thread "main" java.lang.NoClassDefFoundError:
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set my environment variable PATH to c:\program files\java\jdk1.6.9\bin

and I still have to browse over to the bin folder to run javac. so I type in
javac c:\java\CheckForSnap

will that have anything to do with it?
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about that I copy the class and java file over to the
c:\program files\java\jdk1,6,0\bin and it runs. Does not give me the results I want but it runs now
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if These Exercises give you some insight into how the classpath works. Follow the link to Setting the Classpath, too. It seems kind of tricky until the light goes on and you see the relationship between folders and packages and such. Let us know if that makes sense.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works on my computer at home. I think that I was putting path instead of classpath in the environment variables. I will try that when I get back to work Monday.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic