• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run bat file within java

 
Harry Steinke
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bat file with works perfectly when run from Windows. When I try to call it within java I get a
java.lang.NoClassDefFoundError: javax/security/auth/callback/Callback
The bat file uses a vendor jar file.

The following is the bat file with specific info marked out for proprietary reasons.
java -Duser=xxxx -Dpassword=xxxxx -Dhost=xxxxxxxxxxx -Dport=##### -jar c:\xxxxxxxx.jar list agents matching (.*)

The code I am running in my app is:
Runtime.getRuntime().exec("cmd /C start " + [file path] + [bat file name]);

Any suggestions on how to resolve this or where to look for additional information would be appreciated
Thanks in advance.
 
Paul Clapham
Sheriff
Posts: 21111
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That class is built into Java 1.4 and later, so it looks like in that particular environment your "java" command is causing a Java 1.3 JRE to be run.
 
Harry Steinke
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's interesting and confusing. I checked and my runtime and compiler are both set for 1.4.
Anything else you can think of that I could look at?
Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything in that bat file that depends on the "current" directory?
Bill
 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try explicitly setting the classpath in your bat file - that's probably just the first class to get loaded in that package, and it's not finding it.
 
Harry Steinke
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the classpath in the bat file - same error.
I don't know of anything that is using a set directory location. There isn't anything in the bat file except where it points to the jar file that it is using.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off-the-wall idea. Try running a bat file that does java -version

If Java runs at all it should be able to find a class that is in the standard library.
Bill
 
Harry Steinke
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I'll be a ...
The java version that comes up from the bat file is 1.3.1.
I added a cd c:\\ line at the beginning of the bat file that points to my 1.4 version and it works.

Thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic