0

I did below:

subst A: "C\Desktop"

Now from java code:

String command= "java -jar A:\test.jar"
Process process = Runtime.getRuntime().exec(command);

The JVM seems to be hanged here and never executing this line. When i run through "java -jar C:\Desktop\test.jar". It executes succefully.

Does Runtime.getRuntime doesn't resolve virtual hardrive? Thanks

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
yami
  • 871
  • 1
  • 9
  • 14

2 Answers2

4

I assume you have \\t and not \t and you are reading from the error stream so you can see any errors. \t is the tab character.

(The joys of MS-DOS using \ as a path separator ;)

Dump out the error you are getting and you should see the problem.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Oh Sorry, i am not facing any issue of \\t, i will take care of it. My issue is some thing to deal with class not found .I am getting this error: – yami Aug 06 '12 at 09:42
  • Are you using more than one library? A Jar can refer to another jar and if the path does not include the drive letter it may use one you don't expect. – Peter Lawrey Aug 06 '12 at 09:47
  • yes, my jar is using another jar. I tried to run it directly from command prompt and their also see the same issue.So i feel it's not related to virtual drive. I am now trying directly from command prompt fist like: java -cp "A:\depending.jar;A:\mytest.jar" -jar "mytest.jar" but it is giving me error like "Unable to access jar file mytest.jar"..Am i doing something wrong? – yami Aug 06 '12 at 09:56
  • can you do `DIR A:\ ` ? I assume your subst should actually be `subset A: C:\Desktop` – Peter Lawrey Aug 06 '12 at 10:00
  • yes I can, on folder explorer it opens the right location. I am not sure if i cna't do for running java commands – yami Aug 06 '12 at 10:04
  • Try changing to `A:` on the command line and using `java -jar test.jar` – Peter Lawrey Aug 06 '12 at 10:27
  • Hi, I tried again the issue was the Manifest file was forced to use the dependency jars from some specific location. However, if i try to change manifest then it was giving me Security exceptions.There are two ways to solve this issue, either use the class directly in the java code and provide dependency jars in project module or if we want to run it through Runteime.exec then we need to follow manifest structure. Giving -classpath for dependency was not read(not sure why?) – yami Aug 08 '12 at 10:59
1

Javadoc of java.lang.Process says

The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.

meaning you are not either reading or writing the data promptly that causes buffer overflow in the associated process. This could be a possible problem. Please read the article on javaworld and consider implementing the reads and writes in separate threads promptly.

sakthisundar
  • 3,278
  • 3
  • 16
  • 29