3

I have created a Java program that quickly changes the IP Address of my laptop for me. It runs fine on every machine that I test with, so I distributed it to my co-workers so that they could use it as well. One of the techs is unable to open the program though. I have confirmed that he is running Java Version 1.7.0, but when he double clicks on the program (I have packaged it as a .exe with Launch4j) nothing happens. Even if he tries to run as administrator. I wrote a quick "Hello World" program that opens a new window and simply displays "Hello World" just to test his Java. That program runs fine. He is running Win 7 x64, the same as me.

I believe it is a security setting in Java that is not liking the java.lang.Runtime.getRuntime().exec() command, but I've looked through all the settings and cannot imagine what setting is blocking the program from running.

Can anyone give me any ideas on what I should be looking at?

Amarnath
  • 8,736
  • 10
  • 54
  • 81
Ron Butcher
  • 489
  • 7
  • 16
  • 10
    What exactly are you running through `exec` and are there any error messages or exceptions? – Thilo Jan 21 '13 at 06:28
  • 1
    Try running the program from command line using java -jar command to see what exception might be happening. If that does not work try to add debugging messages through the code to know where the code hangs up. – Saleh Omar Jan 21 '13 at 06:32
  • Implement Logger + @SalehOmar Solution.. – Shashi Jan 21 '13 at 06:42
  • I'm running a netsh command through exec. I have not run the program from the command line yet. I will try that next. Here is the code that changes the IP: `String[] IPCommand = { "netsh", "interface", "ip", "set", "address", "name=", intName, "source=static", "addr=", IPAddr, "mask=", NetMsk, DefGW };` ` Process ip = java.lang.Runtime.getRuntime().exec(IPCommand); ` – Ron Butcher Jan 21 '13 at 07:08
  • 1
    1) Go through the Java World article linked in the [`runtime.exec` info page](http://stackoverflow.com/tags/runtime.exec/info) & implement the recommendations. 2) For better help sooner, post an [SSCCE](http://sscce.org/) as an [edit to the question](http://stackoverflow.com/posts/14433367/edit) using code formatting. – Andrew Thompson Jan 21 '13 at 08:13
  • I'm having my doubts the question is answerable in its current state, not until the OP actually does some diagnosis of his problem. – millimoose Jan 22 '13 at 00:23
  • Also, while it's indeed possible that the system has a security policy that blocks `Runtime.exec()` this is highly unlikely unless your app is an unsigned applet. (At any rate it's not a setting you'd find in the Java control panel.) – millimoose Jan 22 '13 at 00:26

0 Answers0