Link to home
Start Free TrialLog in
Avatar of luseng
luseng

asked on

java.net.SocketException: Unrecognized Windows Sockets error: 10106

hi,
i open a socket in my program. when i execute this program from another program (by using Runtime.getRuntime().exec()), the problem occurs. the program i tried to open a socket gives the following exception :
java.net.SocketException: Unrecognized Windows Sockets error: 10106: create

what can be the reason? if i execute the program by itself, there is no problem..
thanks..
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Why use runtime exec btw? Why not

OtherClass.main(stringArray);

?
Or maybe it's not a Java program?
Avatar of luseng
luseng

ASKER

 i exec 4 different programs in this program..   all of them includes Threads, System.exit(0), etc.. if i execute them by calling main, it seems to me that there can be some problems..
   
Avatar of luseng

ASKER

they are java programs..

 for example  : Runtime.getRuntime().exec("a.jar")
>>for example  : Runtime.getRuntime().exec("a.jar")

That particular example, if accurate, makes no sense. Can you give the actual commands?
>>makes no sense

I know you can 'execute' a jar by double-clicking it, but that's only on account of Windows shell integration. The command should really be

Runtime.getRuntime().exec("java -jar a.jar")

(if an executable jar)
>>it seems to me that there can be some problems..

What problems? You're going to have a much better chance of remaining problem-free doing things this way than using Runtime.exec
Avatar of luseng

ASKER

   I use the following commands :  

    String javaexec = System.getProperty("java.home") + File.separator +
                          "bin" + File.separator + "java";

     String cmd =  "\"" +javaexec + "\" -jar " + "a.jar";
            
    Runtime.getRuntime().exec(cmd , env, file);
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of luseng

ASKER

 ok...
  what about using Runtime.getRuntime().exec? what can be the reason of exception? i am  wondering that..
  thanks..
Have you missed my point - i'm saying to *not* use Runtime?
Avatar of luseng

ASKER

 sorry, i missed it.  
  why not?
Because it's introducing a layer of complexity you don't need, that can lead to problems
Avatar of luseng

ASKER

ok, thanks..
Avatar of luseng

ASKER

 do i need to call main class of a.jar?
 
>> do i need to call main class of a.jar?

Yes. If you want to try an interim 'quicker fix' pass all commands to Runtime.exec as a String[], not a String
try running:

cmd /c java -jar a.jar