Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SxS (side by side) configuration

I am facing a very obscure issue, while I am trying to run a java app in Windows, Side by Side (SxS).

I have done all the preparation creating the java.exe.config and java.exe.manifest files, which I have in the same folder with the JRE.

The application runs normally when I invoke it from the command line (by starting a .bat file). The .bat file uses the SxS configured Java (which is the only one in the box I am running the application)

However, when I try to invoke it from inside another Java process (using Runtime.getRuntime.exec()) or ProcessBuilder it seems that it totally ignores the SxS configuration and the child Java process is complaining it cannot find the COM libraries, which were the reason I had to do SxS. I have to add that the parent Java process is also launched by the Java.exe that is configured for SxS. Thus, I would assume that the "Runtime.getRuntime(), ProcessBuilder()" would give me the Java SxS loaded environment.

Doing some further debugging using some windows tools (procexp.exe, procmon.exe) i found out the following: When i start the application from the .bat file the .manifest file is normally read by crss.exe (as it supposed to be). However, when another process is spawned by Java the .manifest file is NOT taken into consideration at all. One possible problem i could think of is that the current directory of the Java.exe which starts the process is not the same as the java.exe.manifest file is located.

The only thing i can think of is a bug/problem (or maybe they call it a feature) in the java launcher.

Does anyone had a similar problem? Could anyone shed any light on the above? Much appreciated.

So far i had tried the following:

  • Run the java process from inside a .bat file. WORKED
  • Invoked the java process from a parent Java process using Runtime.getRuntime().exec(). DID NOT WORK
  • Invoked the .bat file from a parent Java process using Runtime.getRuntime().exec(). DID NOT WORK
  • Used ProcessBuilder setting the current directory where the .manifest file is. DID NOT WORK
like image 467
nikkatsa Avatar asked Sep 16 '13 08:09

nikkatsa


1 Answers

I tested it in my computer and it works. Try:

  • read getErrorStream() from Runtime.getRuntime().exec(...); and send here, if you can't solve this,
  • run process with full path (C:\Program...),
  • compile java program to .jar, put in to folder with .bat, open CMD, set current directory to this folder and run jar file (using java -jar filename.jar),
like image 170
barwnikk Avatar answered Oct 22 '22 15:10

barwnikk