• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

run bat file within java

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anything in that bat file that depends on the "current" directory?
Bill
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic