Question

I'm trying to use processbuilder to spawn a new JVM in eclipse with java 7 u51. Unfortunately, I am having a problem with the path ( String path = System.getProperty("java.home"); ) when the processBuilder attempts to use it.

Here is the problem code

String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home");
System.out.println("Seperator = " + separator + " classpath = " + classpath + " path = " + path);

ProcessBuilder processBuilder = new ProcessBuilder(path, "-cp", 
    classpath, Transcriber.class.getName());
Process process = processBuilder.start();

Here is a look at the console output

java.io.IOException: Cannot run program "C:\Program Files\Java\jre7": CreateProcess error=5, Access is denied
Unable to call transcribeConvo
    at java.lang.ProcessBuilder.start(Unknown Source)
    at TranscribePanel$2.run(TranscribePanel.java:131)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 7 more

I tried adding the jvm.dll directly to the eclipse.ini but it didn't have an affect. Any help would be great. Thank you :)

Ps: If I didn't provide enough information please let me know.

Was it helpful?

Solution

The path "C:\Program Files\Java\jre7" is not the path to an executable file, hence the error. if you want to execute the java executable, then you need to actually provide the full path to it, probably "C:\Program Files\Java\jre7\bin\java.exe."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top