B4J Question Address Already in use : JVM_Bind...?

Ydm

Active Member
Licensed User
Longtime User
I made a socket application with B4A and B4J. Everything works fine.
However, the application I wrote with B4J sometimes gives an "Address already in use" error. When I look at the task manager, I see that JAVA is working.
How can I check this status when opening the application? How can I prevent this error?
 

Ydm

Active Member
Licensed User
Longtime User
Thanks. I downloaded and run your application. However, it could not find a running application. How can I find java paths that are open on users' computers? Ultimately, everyone will have a different path.
 
Upvote 0

Xandoca

Active Member
Licensed User
Longtime User
In Windows OS you can execute the following DOS command to list java applications for example.
B4X:
wmic PROCESS WHERE NAME="java.exe" get caption, commandline, Processid
With this information you can kill the process (for example) or ...
Hope this help.
 
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
This app manages only java processes that run on the computer where the app is executed.

Perhaps you can use the code of my app to make a launcher tool: You run the launcher, which checks if a specific java process (i.e. your application) already runs. If it does, it kills it and then runs your application. Then the launcher is terminated.
 
Last edited:
Upvote 0

Ydm

Active Member
Licensed User
Longtime User
Thanks for your answers first.
Let me explain in a little more detail.
I made ServerSocket application. I close this application. But java continues to work. Sometimes when I try to open it again gives the following error. "java.net.BindException: Address already in use: JVM_Bind"
Here is the line where he made a mistake:
"server.Initialize (PORT," server ")"
Before that, I have to check this component. I have to kill if it is in use.
Is there a way I can do this practically?
 
Upvote 0

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
If I understand your problem correctly, you have a non-UI app which runs a server. If the app, for some reason, is not terminated, then when you try to run the app again, you get the error that the server's port is already in use. So, in order to run it again, you need to check if an old instance of the app is alreaydy running and stop it - thus freeing the port - and then run your app.
If this is the case, you can probably achieve this with my suggestion in post #5.
 
Upvote 0
Top