tags:

views:

51

answers:

2

I have a stanalone application with a main class which used to run a windows BAT file ,the BAT file which invoke another java class(B),the class B refer so many JARs and configuration files which i configured through "build Path"

Now I want to refer the JARs and configuration files in BAT file.How I write the BAT file.

A: 

Is the program specific to one machine or does it need to be generic?

The issue would be, I think, would be how to get a jar file to return something outside of java. The obvious answer would be, use the batch file to run the java. Write the java so that it writes its 'return value' to a file. Write the batch file so that it watches for the file/dir that the java writes to, and looks for the changed/new data and then use it.

Quinn1000
A: 

If you can make sure the .bat file and all needed jars are located in the same directory, this is quite easy:

rem sets the basedir to the directory where this batch file is locaed
set basedir=%~dp0

rem build the classpath for the Java command
set cp=%basedir%\jar_one.jar
set cp=%cp%;%basedir%\jar_two.jar
set cp=%cp%;%basedir%\jar_three.jar

(and so on...)

rem start your second class
java -cp %cp% your.package.ClassB
a_horse_with_no_name