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.
Related
Recently, when I go to run a java program with the command java and then hit tab to autocomplete the .class file it just freezes. I have to hit control+c to kill it and I get the message Killed by signal in _java_class after 4s. I have tried googling but can't seem to find anything on it. javac + tab works as expected.
This problem is not related to Java at all. As you state it, the JVM has not even been started. Try to figure out what your shell is trying to do when you hit the tab key for autocomplete.
I guess it might even go scanning the filesystem for a suitable main class and whilst at that running into all kinds of trouble.
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.......
!>...
I'm developing a standalone server (not a war) using Eclipse Juno. I run it as a Java application from Eclipse. After I've made some code changes, I want to stop the currently running server and start it up again. I do this tens of times a day.
The way I do that at the moment is as follows:
- Go to the "Debug" tab.
- Select the server process.
- Click on the stop process icon (red square).
- Click on the green arrow to re-run the last run application.
- Go back to the "Java" tab.
Is there a quicker way?
Ideally, I'd like a button or keyboard shortcut that would stop and restart the application in one click. If it doesn't already exist, can I extend Eclipse in some way? Where should I look for an example of something like this?
You can restart running application by right clicking it in debug window and selecting "Terminate and relaunch".
And quickly switching beetween views with Ctrl+F8
Also if you've already terminated the application from console, you can simply hit ctrl + f11
If you really want you can also add custom shortcut for terminating and relaunching by Window -> Preferences -> General -> Keys -> Find "Terminate and Relaunch" and choose your favorite key combination!
Eclipse Neon.1 added a way to terminate before relaunch by holding Shift while clicking on a launch history item.
You can also make that the default behaviour by enabling the option “Terminate and Relaunch while launching” in Preferences › Run/Debug › Launching.
https://www.eclipse.org/eclipse/news/4.6/platform.php#terminate-relaunch-history
I had the exact problem you had. I had a simple Java class with a main method that runs an embedded tomcat.
When I change any of my service classes, I wanted to terminate the current embedded tomcat and relaunch with one single keystroke.
I know, I could have just clicked and done the same with 2 mouse clicks... but... it pained me enough to learn a wee wee bit about Eclipse plugin and threw something together.
Hope this helps you too.
https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home
Simply saying, You can't modify eclipse Like you wants to. But You can follow this procedure to minimize your effort
1. In Eclipse Project TAb-> Check Build Automatically.
2. And After Every Changes You are making Just Run The Project using Green button in eclipse.
Also you Can use CTRL+F11 to run project.
I want to install a monitoring system on a computer (the program is a jar file) and run it on start up every time any user logs on. However, I don't want the user to be able to terminate it since then it won't be able to be monitored any longer.
We have tried several ways:
Installing it as a service - the problem here is that our program doesn't work any longer; it can't connect to the computer that's monitoring it. We used "Yet Another Java Service Wrapper" for this, and looked into some other wrappers as well that could help us install it as a service.
Running the program on start up (using the folder startup), but not giving the basic user the privileges to edit/delete/mess around with the files. However, this seems to slow the whole computer down? This doesn't happen when we run the bat file executing the jar directly. Another issue with this is that the user can just go to the task manager and kill the java process.
We tried a variation of the previous one to solve the issue of the process being killed, by having another process. One will spawn the other and these 2 processes will keep tabs on each other. If one terminates, the other detects it and runs it to start it up again. Although it can have issues if the user is fast enough in killing both processes before either is respawned again, the bigger issue is that it sometimes has problems with connecting to other computers. We didn't have this problem when it was just 1 jar.
Does anyone have any idea on how these problems can be solved?
The context here is windows, but if you have suggestions for linux and mac that would be nice too!
Way to go is to run the program as a service. You should investigate any trouble between your application and your system's firewall. If you have windows firewall activated, you should add an exception for java.exe or javaw.exe.
In order to give elevated privileges to your program, you can set the service to run as another user. You can do this from the "Log on" tab in the service properties.
You'll want to have the program started under a user with elevated permissions. On WIndows this would the the Administrator, linux would use root. On Windows, its likely that you will need to start it as a service. But I really don't know why that would hinder the network communications.
I am developing a Flex-based game, and struggling with SmartFox Server.
Anyway, it's a java-based server for Flash platform games, and it's kind of clunky to develop with on Windows. So, I want to be able to start it (and stop it) via Eclipse rather than the current batch file nastiness they provide.
The problem is I've never done that with a non-standard server that didn't just have a server adaptor in Eclipse.
I know it should be pretty simple, but how do I do it? It's really just a matter of calling a command line executable with some arguments, or even just running it as a Java application without its executable shell. Killing it would just be a matter of killing the process in Eclipse.
Also of note is that I want to make sure I have the shell output in Eclipse for debugging purposes.
I would think you could run it as an "External Tool" from Eclipse (the little green arrow with the toolbox). Click on the menu arrow to the right of that icon and select the "Configure External Tools" option.
You can then right click on the "Program" tree-node (on the Left hand side) and select "New" to create a new configuration. You will need to fill in the values similar to what you would do if you were running the server on the command line.
Give your configuration a meaningful name, like "SmartFox" or something.
Location is the command that is run (might point to java in your case).
To get the console setup, click on the "Common" tab and the "Allocate Console" checkbox should already be checked.
Once you are done, press the "Apply" or "Run" button.
You can then start the server by selecting it from the "External Tools" list (same icon as earlier) and you can stop it using the red stop icon on the console (should work).
Optional... the other tabs of the configuration dialog may be useful. You might want to have the build tab not do a build before launch, depending on how you have things set up.
What this wont give you (necessarily) is the tight integration between the server and Eclipse. You may have to do additional configuration or just deploy your code to the server as necessary.
Hopefully I am not way off base of what you were looking for.
Good luck.