• Post Reply Bookmark Topic Watch Topic
  • New Topic

Restart a Swing Application from within  RSS feed

 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there any means to restart a Java Swing application?

Thanks,
Renjith
 
Pierre Sugar
Ranch Hand
Posts: 62
Java Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you want to do?

If you have an application that is invoking a JFrame, e.g. myFrame and you dispose myFrame you can afterwards "restart" (means show) it from the calling application by invoking myFrame.setVisible(true).
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pierre,
You might have seen certain applications, after new plugin installation, prompt user to restart the application. Same technique I am looking for.
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to really restart your application, you will have to launch a new process, then close the existing one.
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, can you make it more clear as how to do in Java?
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a search on how to start a process. There have been many such threads in our Java in General (intermediate) forum.

What may be a problem is the total command to execute. Sure, the "javaw" and main class name are not that hard. But the other command line parameters may cause a problem; the class path in case the application is started from a JAR file, the memory flags, etc.

At least you can copy all system properties: read System.getProperties(), and add all of them using a "-Dproperty=value" flag.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be easier to generate a script file and invoke it in the process.
Once the application is restarted, this script file can be deleted.
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It might be easier to generate a script file and invoke it in the process.


Confounding! I dint understand. Maneesh, Could you make more explanatory as what to do in each step?


 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Good God! it's working

Thanks Maneesh You saved me.

Can I make this batch file launch from webstart applications?


 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose you could as long as you took care of the permission issue...and somehow managed to successfully run the .bat extension on non M$ platforms
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Have you ever tried using .bat files in JNLP?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
Why would anyone want to do that?
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a following scenario:

1. Application is launched using JNLP
2. It is multi-lingual application.
3. User clicks change language button to localize. Like web application, any provision to refresh entire application to reflect language change. Or should we go for application restart?


 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Renjith Mohan wrote:
I have a following scenario:

1. Application is launched using JNLP
2. It is multi-lingual application.
3. User clicks change language button to localize. Like web application, any provision to refresh entire application to reflect language change. Or should we go for application restart?




If it's multi-lingual, how you keeping track of the various languages (eg properties files like most web apps do)? When you switch language for a website, does the browser (in our case the app) restart? Only the page refresh - so ideally only the JPanel/JFrame/window refresh reflecting the new language. Also since you deploying using JNLP, I'm sure those language files are part of the deployment.
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I maintain a message bundle (a .properties file) and the application prompts user to restart each time when the language is changed. Before the application closes, it writes the last modified language as the current language in a config file. So next time when the application loads, it reads the config file, and display the last used language.

Apart from doing this, I want to make the application either refresh fully so that the changes are effective or restart by its own.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!