aspose file tools*
The moose likes Java in General and the fly likes Exception error:Cannot run program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception error:Cannot run program "C:\Users\x\Desktop": CreateProcess error=5, Access is denied." Watch "Exception error:Cannot run program "C:\Users\x\Desktop": CreateProcess error=5, Access is denied." New topic
Author

Exception error:Cannot run program "C:\Users\x\Desktop": CreateProcess error=5, Access is denied.

syed vaseem
Greenhorn

Joined: May 03, 2011
Posts: 6
import java.io.PrintStream;
import java.util.*;
public class NewThread implements Runnable{
Thread t;

NewThread(){
t = new Thread(this, "Demo Thread");
System.out.println("child thread:" + t);
t.start();
}


long startTime = System.currentTimeMillis();
public void run(){
Runtime r = Runtime.getRuntime();
Process p = null;
String s = "C:\\Users\\x\\Desktop\\ java -jar helol.jar";

try
{
p = r.exec(s);
p.waitFor();

}
catch (Exception e)
{
System.out.println("Exception error:" + e.getMessage());
}
System.out.println("Project1 returned:" + p.exitValue());
System.out.println("child thread exiting ");
long endTime = System.currentTimeMillis();
System.out.println("Total elapsed time in execution of given .exe file in milliseconds is :" + (endTime-startTime));
System.out.println("Heap utilization Statistics in Bytes");
System.out.println("Used Memory:"+ (r.totalMemory() - r.freeMemory()));
System.out.println("Free Memory:"+ r.freeMemory());
System.out.println("Total Available Memory:" + r.totalMemory());
System.out.println("Maximum Available Memory:" + r.maxMemory());

}
}

class ThreadDemo {
public static void main(String args[]){
new NewThread();
try {
for(int i=05;i>0;i--){
System.out.println("Main Thread:" + i);
Thread.sleep(1000);
}
} catch (InterruptedException e){
System.out.println("Main thread Interrupted");
}
System.out.println("Main thread exiting");
}

}


please help me out ASAP... i am trying to execute a jar file through this program in eclipse but it's showing an error - createprocess=5 access is denied and i tried to change the permissions of respective folders and directory but couldn't work and i made changes in configuration file of eclipse i.e eclipse.ini but still i am facing prob.
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

split your command into



and use http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String[])

- Chinna
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

String s = "C:\\Users\\x\\Desktop\\ java -jar helol.jar";

There is a space before java, I think may be that is the error.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

Are you sure that your "java" executable is located in C:\Users\x\Desktop? Because that's what you're trying to do here (apart from the space).
I think you want to execute "java -jar helol.jar" from directory C:\Users\x\Desktop. There's an overloaded exec method for that:
And when you're working with Runtime.exec or ProcessBuilder, make sure to have read When Runtime.exec() won't.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
syed vaseem
Greenhorn

Joined: May 03, 2011
Posts: 6
thanks for everyone.... 3rd post by ROB SPOOR is working....i am really so happy that i got solved my prob... thanks to everyone............... love this forum
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

You're welcome
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Hi Syed Vazzz,

Next time please UseCodeTags when posting code in the forums. Unformatted code makes it hard to read.

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
syed vaseem
Greenhorn

Joined: May 03, 2011
Posts: 6
yeah sure sir
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception error:Cannot run program "C:\Users\x\Desktop": CreateProcess error=5, Access is denied.
 
Similar Threads
How long a thread has been running
Multi Threading
Threads
Thread qstn
createProcess error=193, %1 is not a valid win 32 application