• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Launching a jar from startup in windows

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a javafx application "MAIN_PROGRAM.jar".
I would like the option for this to run as soon as pc boots up into windows.
If I put the jar file directly into startup folder, then the user is unable to delete this jar from the programs gui,
since it would be deleting itself while its still running which doesn't work.
So I came up with this idea:

Store the MAIN_PROGRAM.jar in a specific place (in the home folder), then let it
copy(or delete) as required, a small jar file, that can launch the MAIN_PROGRAM.jar file, using:


This seems to work most the time, but not every time, which is annoying.

My third try was to launch the MAIN_PROGRAM.jar using a bat file.


This seems to work, but the command prompt always flashes quickly on startup,
and the person I'm writing project for doesn't like this.

Are there any better solutions to the problem?
Thanks very much for any help.

 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put the .bat file in your installation folder.
Create a shortcut to the .bat file which you put in the startup folder
Right click on the shortcut and select 'Properties'
Select the 'Shortcut' tab
In the 'Run' drop down select 'Minimized'
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marvellous, actually works, thanks!

Previously been using a shortcut to the jar itself.
It seems to be having issues on Windows 8, sometimes would start, sometimes not.
Might be related to using battery or ac power, still trying to get to the bottom of it.

Out of interest, is a shortcut to the jar itself better/worse than the shortcut to the bat which launches the jar,
in your professional opinion?

Thanks again.

 
Tony Docherty
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It really depends on what you are doing. For example:
If you want/need to pass command line arguments to the JRE then use a batch file.
If you want/need to pass command line arguments to the application then use a batch file.
If you want to control which JRE runs the application then use a batch file.
If your application can be run without the above then use a shortcut to the jar.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, never thought about the argument list.

Seems normal shortcut will suffice for me, but batch file could be better in terms of changes in the future.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic