wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Help with something Simple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with something Simple" Watch "Help with something Simple" New topic
Author

Help with something Simple

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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

Joined: Sep 04, 2004
Posts: 282

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

Joined: Sep 04, 2004
Posts: 282

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

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with something Simple
 
Similar Threads
Which class is suitable ?
how to do it??
Another Runtime Problem
Appending to text file
Ocurrio un error:java.io.IOException: Stream closed