0

I need to execute a jar file on HP-UX that I am not supposed to modify.

I unpacked it using jd-gui and found out that I am failing cause in java there is a condition to check the os, leading to different directions for win, macos, freebds, openbds, gnu and so on.

I am quite sure everything would work if I would be able to make my unix command line reply freebds or openbds to the java call

System.getProperty("os.name")

once executed from a jar file like:

java -jar myjar.jar

is there a way to achieve this? some kind of compatibility mode or a way to preset that parameter.

stat
  • 699
  • 3
  • 10

1 Answers1

3

You can use the -D switch to specify system properties. In my experiment this (unexpectedly) even worked with pre-defined ones like os.name. Therefore this should work:

java -Dos.name=linux -jar myjar.jar
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614