2013年8月4日星期日

bat calls jar package and pass multiple parameters

 

following main program through eclipse to write:

 

1. bat file in the Main function receives the parameters passed (String [] args)

 

such as: String ip = args [0];
String user = args [1];
; String password = args [2];

 

2. package the project

 

@ install plug fatjar

 

decompression plug "net.sf.fjep.fatjar_0.0.31.zip" on the eclipse \ plugins directory

 

@ restart Eclipse right-click the project '"Bulid Fat Jar"

 

[Jar-Name] Enter the name of the generated jar; [Main_Class] to select the main class;

 

3. jar package at the same level in the exported directory to generate the corresponding bat file

 

============================================= ================================================== =

 

@ echo off
: start
cls
echo ================ database selection ========== ==========
echo sure to carefully check -
echo 1. database connection: jdbc: oracle: thin: @ 10.133.10.120:1521: orcl
echo (2) manually entered into the database
echo 3. Exit
echo ================================ ==============
set / p choice = Please select:
if% choice% == 1 goto 1
if% choice% == 2 goto 2
if% choice% == 3 exit
: 1
set ip = 10.133.10.120:1521: orcl
set user = sjpt_gd
set pass = sjpt_gd
cd F: \ bat
java-jar-Xms512m-Xms1024m batProject_fat.jar% ip%% user%% pass%
echo ============= ===== interface to access the end ================
echo ======= To run again, press Enter twice to == ========
pause
goto: start
: 2
cls
echo ============== == parameter value is set ====================
echo server address format: 10.133.10.120:1521: orcl
echo database connection: jdbc : oracle: thin: @ 10.133.10.120:1521: orcl
echo ================================ ==============
set / p ip = Please enter the server address:
echo% ip%
set / p user = database user name: < br /> echo% user%
set / p pass = database user password:
echo% pass%
cd F: \ bat
java-jar-Xms512m-Xms1024m batProject_fat. jar% ip%% user%% pass%
echo ================== interface to access end ============= ===
pause
goto: start

 

============================================= ================================================== =

 

this way can be used after bat file called

 
    
 

 

2 条评论:

  1. I've got the exercise on sun networking tutorial to work so now need to spend more time on how it works.

    回复删除