How do you stop a Java RMI application in Eclipse? - java

I followed some tutorials (i.e this one)on Java RMI in Eclipse and got the program running.
The trouble is, I can't find any instructions on how to stop the RMI program from running. I want to know for general knowledge purposes, but also because when I try running the program again (after making changes) I get a message that the port is already bound to the previous run which is still active.

The button on the right can be used to toggle between active output consoles. When you reach the console for the RMI server you want to end, click the red square (on the left)

Related

Is it possible for Eclipse to only open one JFrame?

When run the project second time, can the previous JFrame closed before open the new one ?
So I no need to close the JFrame when trying to run the project second time.
Is it possible to open only one JFrame?
Eclipse has the possibility of terminating the launched program before starting the new one:
It is called Terminate and Relaunch (see the Documentation).
You can bind this to any shortcut you like (Window -> Preferences -> General -> Keys).
Apparently, eclipse offers some special options to get what you want.
For other people who might be using a different editor: it's possible, but you'd need some kind of communication between the processes.
What you can do is this, make a server application that runs independently and have it open before you start your regular application. When you run your regular application, connect to the server. This server now messages the other application that was running to close down.
If running a server application is too much trouble, you can run both the server and the client in the same application. When you start the application, check if the designated port is busy, if not, create a server. If it is busy, connect to the server and tell it to shut down. After that, open the server socket in the new application.
Select the Terminate and Relaunch command [ Terminate and Relaunch ] to first terminate the selected debug target and secondly, relaunch it.
Once a launch is terminated it can be automatically removed from the Debug View. To change this setting use the Opens the Launching preference page Run/Debug > Launching preference page.
you may find relaunch-plugin for eclipse useful for your case.
I don't know about eclipse but i usually run two or more JFrame applications in (IntelliJ idea) belonging to different classes at a time. The previous one will not be closed. One more thing i would like to suggest you to use IntelliJ Idea from Jetbrains company as the UI,shortcuts and all other stuff are same as in Android Developer kit(studio) which is also sponsored and developed by Jetbrains!..
You can check the JFrame applications running simultaneously in this image.
Hope this answer is somewhat informative.......
!>...

Why does Debugging Native code using GDB of a JAR application hangs Ubuntu UI (X11 Process) when breakpoint is hit?

My project is basically a Communication client like lync which is developed in JAVA for front end (GUI) and uses platform specific native (C or C++) code for running services.
Now, on Linux, (Ubuntu 12.04), once the JAR application is invoked, it loads all the native code shared libraries and the UI thread starts executing. Any action done in the UI will throw an event to the native code which is in C. So currently i need to debug a crash in a C/C++ user library which is triggered when i do something in a UI drop down.
I am using GDB, to attach to the PID of the process , (sudo gdb -p ), all the symbols are loaded and i am able to set a breakpoint to a function say A() in the library.After continue command in GDB, i select the instance from UI Dropdown and breakpoint is hit at Function A(). At this moment, my ubuntu machine hangs and no keyboard interrupts are working. I am only able to move my mouse pointer but cannot click on anything.
However, to verify that kernel is not down, i can ping the machine and even SSH is possible. Once the same GDB is invoked by SSH the above problem is not encountered. May anyone please help me out here as to why UI or X11 process hangs during the above scenario.
PS: Yes there are lot of threads running, it might be a thread deadlock situation but it does not happen when GDB is invoked by SSH terminal.
Thanks and Regards,
Indra
why UI or X11 process hangs during the above scenario
As Mark Plotnick correctly pointed out, the X11 process does not hang. Rather, it grabs the keybard (all keyboard events are dispatched to it), and can not release that grab (it is stopped by GDB before it reaches the release point).
There are two common solutions:
ask the application to not do the keyboard grab (as Mark said), or
debug the application from a separate machine (this can even be done on single physical machine: just run the application inside a VM).
P.S. Why do application menues grab keyboard? Because hitting Esc usually dismisses the menu, and they want to see that Esc regardless of whether the application has input focus or not).

Restarting a Java Program Within Eclipse

I own a game server and I was just wondering, instead of running the server in eclipse and then when I restart it, it opens a new cmd prompt outside of eclipse and runs the server on that. Could I make it so the program relaunches in eclipse as if I hit the green play button?
I was reading your comments on this post. You said that you don't want to kill the program and then restart from within eclipse. So you have two options.
Bad Answer: Just press ctrl + F11 (relaunch the application and ignore the old one)
Good Answer: Press F11 then go to what looks like a computer in the console tab. You can select the previous running program and kill it and the second one will still be running.
If what you want to do is transfer the data and keep it the same run time state, well to say the least that is going to be some what complex. I would make some kind of method to transfer all current data and call it from your constructor. Then start your second program and kill the original. I'm 90% sure all your users will get booted though.

Java program blocking ports?

There is a program called PC^2 (a programming contest judging system). You can submit java files to it, and it will compile/run it.
I have a program that creates a socket, when I submit this to PC^2 it runs it fine, but I can't access the url (http://ip:port/) on my web browser. But when I quit PC^2 (my program is still running) it works when I hit refresh on my web browser. This means that PC^2 is somehow blocking the port, but not occupying it (i.e. making it's own ServerSocket that occupies the port) because if it was occupying it, then my program would have thrown an exception and quit.
What are possible ways that a Java program can do this? And since PC^2 is closed source, I can't look there.
Only one program at a time could listen to a certain port.
Same happens if you start tomcat twice using the some port
This has nothing to do with java. That is how sockets work
If PS^2 is running locally, you could check to see if it's listening before you run your program. I saw PS2 Version 9 uses sockets for communication, so perhaps that's what's going on? In Windows, these instructions will help confirm which process is listening on the ports. In linux, this page will help.

Causes of a hanging Java console

I have a problem.
Sometimes when I close my Java applet using the "Close button" in the upper right corner, the console freezes and becomes nonrespondable. The Java process does not shutdown and proceeds to use the maximum of a CPU.
It is only in one of ten times that this happends. It is also not dependant on browsers.
I have made sure that all my threads are properly shutdown along with my threadpool executors.
This is also only happening in applet mode. When I run this in Netbeans, I have never encountered this problem.
I am using Netbeans on Windows.
What could be the reason for the Java console to be hanging like that ?
And how can I determine what the causes of this hanging could be ?
Run your applet in debug more (see here how to do it in Eclipse).
Create a remote debug launch config (see link above).
Close the applet
When the bug happens, start the remote debug launch and pause the whole VM. Now you can inspect the threads to see what happens.

Categories

Resources