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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Why use runtime exec btw? Why not

OtherClass.main(stringArray);

?
0
CEHJCommented:
Or maybe it's not a Java program?
0
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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
CEHJCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.