Search code examples
javalinuxjarjavacexecutable-jar

converting a shell script to a jar file


I have a following sh file.

%~d0
 cd %~dp0
 java -Xms256M -Xmx1024M -cp ../lib/systemRoutines.jar;../lib/userRoutines.jar;.;sqlldr_0_1.jar;../lib/dom4j-1.6.1.jar;../lib/jakarta-oro-2.0.8.jar;../lib/log4j-1.2.15.jar; migration_test.sqlldr_0_1.sqlldr --context=Default --context_param cred_username=cre --context_param cred_password=crepass --context_param cred_env=credev01 %*

What I would like to do is to convert this sh file into .jar file. The result jar file will be run by another program. How can I do so?

Thanks in advance :-)


Solution

  • If you are not going to modify your shell file, then you can use a java code to execute these commands and then build that into a jar.

    How to run linux commands in java code?

    Please keep in mind to include everything in a single execute() call as the above method executes your linux command in a separate process.