i am trying to run a jar file on a linux machine which contains a java code which is trying to execute another .jar file. After going through forum suggestions i tried to create a symbolic link between "/usr/bin/java" and "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java /usr/bin/java". Also i tried reinstalling java 7 but no luck.
command that i am running on linux machine
"java -jar RSFlowInvoke.jar -host -flow -u "user" -p "password"
this further executes a jar file using below method
if(osname.toLowerCase().contains("linux"))
{
String currentPath=Paths.get(".").toAbsolutePath().normalize().toString();
cmd = "java -jar JRSFlowInvoke.jar";
// tried this simple command also..no luck
// cmd = "java -version"
ProcessBuilder builder = new ProcessBuilder(cmd).directory(new File(currentPath));
//.directory(new File(currentPath2+"/originalJRS"))
Process process = builder.start();
StringBuilder output = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String Line;
while ((Line = reader.readLine()) != null) {
output1.append(Line + "\n");
}
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("Flow launched successfully !!!!");
System.out.println("----------------------------");
System.out.println("\n");
System.out.println(output1);
System.exit(0);
} else {
//abnormal...
}
}
it throws this error :
java.io.IOException: Cannot run program "java -jar JRSFlowInvoke.jar" (in directory
"/home/employers/JRSFlowInvoke/originalJRS"): error=2, No such file or
directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at simpleCommand.main(simpleCommand.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:187)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 6 more
I made sure that the file is present at the directory.
Any help is really helpful...