Link to home
Start Free TrialLog in
Avatar of royalcyber
royalcyber

asked on

running the java utility from unix shell script

Hi experts,
               i have an issue with running a java file from a unix shell script. The java file i am running is part of a jar file. The java file takes 2 args. The windows equivalent to what i wud like to achieve is the following :


C:\Program Files\Java\jre1.5.0_13\bin\java.exe  -cp C:\Util.jar; com/util/Deploy Arg1 Arg2

Where C:\Utill.jar is the jar file which contains the class Deploy which takes 2 args.

Please help me achieve the same in shell script on unix ..

thanks in advance
               
Avatar of oleber
oleber
Flag of Portugal image


The command is +- the some

java  -cp /path/Util.jar com/util/Deploy Arg1 Arg2

in my pc the Java is in:
/usr/bin/java
Avatar of jmlon
jmlon

Three observations:

1). Under Unix/Linux the semi-colon is and end-of-command marker. To separate multiple paths in the classpath use colon.

2). Both previous examples have a syntax error if the class is named Deploy and is in the package com.util. The correct unix command line is:

java  -cp /path/Util.jar com.util.Deploy Arg1 Arg2

3). If you define Deploy as the main class within the manifest file, you can simplify things even more:

java  -jar /path/Util.jar Arg1 Arg2
ASKER CERTIFIED SOLUTION
Avatar of bhaskar20001
bhaskar20001
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial