• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Restart a Swing Application from within

 
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there any means to restart a Java Swing application?

Thanks,
Renjith
 
Ranch Hand
Posts: 62
Ruby Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22768
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob, can you make it more clear as how to do in Java?
 
Rob Spoor
Sheriff
Posts: 22768
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.jroller.com/santhosh/entry/make_you_application_restart_on
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Have you ever tried using .bat files in JNLP?
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic