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..
lusengAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Personally i would attack this problem by first lowering the complexity of invoking the programs in the first place, and that means calling their main methods. They'll also start much faster if you do that
0
 
CEHJCommented:
Why use runtime exec btw? Why not

OtherClass.main(stringArray);

?
0
 
CEHJCommented:
Or maybe it's not a Java program?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lusengAuthor Commented:
 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..
   
0
 
lusengAuthor Commented:
they are java programs..

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

That particular example, if accurate, makes no sense. Can you give the actual commands?
0
 
CEHJCommented:
>>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)
0
 
CEHJCommented:
>>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
0
 
lusengAuthor Commented:
   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);
0
 
lusengAuthor Commented:
 ok...
  what about using Runtime.getRuntime().exec? what can be the reason of exception? i am  wondering that..
  thanks..
0
 
CEHJCommented:
Have you missed my point - i'm saying to *not* use Runtime?
0
 
lusengAuthor Commented:
 sorry, i missed it.  
  why not?
0
 
CEHJCommented:
Because it's introducing a layer of complexity you don't need, that can lead to problems
0
 
lusengAuthor Commented:
ok, thanks..
0
 
Venci75Commented:
0
 
lusengAuthor Commented:
 do i need to call main class of a.jar?
 
0
 
CEHJCommented:
>> 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
0
 
objectsCommented:
try running:

cmd /c java -jar a.jar
0
All Courses

From novice to tech pro — start learning today.