File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
Java in General
errors when using bat file to launch .jar
Jeremy James Brown
Joined: Mar 24, 2011
Oct 15, 2011 20:23:11
I am facing a strange issue. My code runs just fine from Netbeans or cmd with
> java -jar MP2.jar
but when I try to run it from the .bat
"%JAVA_HOME%"\bin\java -jar .. \dist\MP2.jar > test_mp2_out.txt
I get just error in my text file
DataIn\nrmavg.txt (The System cannot find the path specified)
or a null pointer exception at the line I have new
I can provide more code if needed, but I think this may be a windows problem.
Stephan van Hulst
Joined: Sep 20, 2010
Oct 16, 2011 09:24:23
This is a guess, but the file you're trying to read is probably in some folder relative to your working directory, and the working directory is different when you run the code from your batch file.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
It is sorta covered in the
JavaRanch Style Guide
subject: errors when using bat file to launch .jar
How do I deploy my application using a jar?
run bat file within java
Not able to call a bat file from JAVA
Java Web Start
how to run a .bat file from java program.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015