java - Difference behavior when executing the jar file from command prompt and double click a jar file -


I am using Windows 7 and Java 1.6.0_22 is my default Java version.

I am using a jar file which is an open source jar file (webscarab-selfcontained-20070504-1631.jar) to act as an intermediate proxy.

When I execute the jar file, double click the jar file and at the command prompt, execute the Java-jar webscarab-selfcontained-20070504-1631.jar command at the command prompt.

When I hit the url by setting a default proxy for jar, it is capable of receiving a proper response when the jar is executed by double clicking and receiving invalid response when executing the jar file from the command prompt. .

Please let me know what's the difference between double clicking and executing jar file from command prompt ...

After doing more research on this, I found a solution.

The difference, when double click on the jar file, it will be updated with the class path in the registry, ick is updated, in my case, the Java 7 bin path is updated in the registry, which is jar Implemented in Java 7.

While executing the jar file from the command prompt, the Java version that we have updated in the Environment variable (default version), will be created to execute the jar in the bar. This is the reason why I get two behaviors that double click and execute from the command prompt.

How to update the registry: (in the Windows system)

  1. Open the CRTL + R -> run command
  2. Type regedit
  3. Navigate to HKEY_CLASSES_ROOT \ jarfile \ shell \ open \ command
  4. You want to update the path Ex: "C: \ program files \ Java \ jre6 \ bin \ javaw.exe" - Jar "% 1"% *

Now double click jar file will be run in java6 and will receive the same behavior ... ..


Comments