1

Recently I developed a jar file with JavaFX. Now my problem is how to convert it into an executable so it can install and run on other systems which do not have any JDK installed.

Also, when the client system starts from shutdown or hibernate I'd like the executable to run automatically.

I searched a lot on Google and I found content on the internet, but I did not find how I can achieve this.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
Rocky
  • 319
  • 3
  • 8
  • 23
  • You can directly click the jar you created,it will run if atleast JRE is available. For auto start, you can place the jar file in the startup programs folder of make it a service. – Harshit Apr 30 '18 at 10:56
  • @HarshitShrivastava thanks for your replay problem is that my client system does not java install in their system and another thing how i can make services – Rocky Apr 30 '18 at 10:59
  • For running the java application, you must have atleast JRE installed. For Windows Service, you can get the tutorial on various sites https://stackoverflow.com/questions/1617458/how-to-create-windows-service-from-java-jar – Harshit Apr 30 '18 at 11:03
  • @HarshitShrivastava thanks for your replay and how I can make installer for exe – Rocky Apr 30 '18 at 11:32

1 Answers1

2

how I can convert it into exec with the install so it can install into other systems which do not have any JDK on that system

You always need the JRE to run the jar file, there's no way around that. However, since the assumption that almost all systems would have the JRE installed is no longer correct, the normal thing these days is to bundle the entire JRE with the installer and use launch4j to create an exe file.

and another thing I want is that when client system start from shutdown or hibernate exec should run automatically.

You can't do this at the Java level, so it depends what OS you're running on. On windows you could use sc.exe to create a windows service from the executable, or you could just put it in the relevant user's startup folder.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
  • thanks for your reply will this thing every time i.e it run automatically exec without a user interaction – Rocky Apr 30 '18 at 12:57
  • Yes, launch4j is just a thin wrapper, no user interaction required - it just launches the underlying jar. – Michael Berry Apr 30 '18 at 12:59
  • I mean when client window system start will my exec run automatically using this sc.exe to create a windows service from the executable I don't want user interaction sorry for asking too much – Rocky Apr 30 '18 at 13:04
  • if you create a windows service from the executable, then you can set this service to run automatically, and in that case yes it will start in the background without user interaction. – Michael Berry Apr 30 '18 at 13:05
  • thanks for your response actually I got too much confused about this line sc.exe to create a windows service from the executable i mean when and how i can execute this line I m just going to give the client a simple executable file so he don't have idea of running service or open cmd and type this line sc.exe command – Rocky Apr 30 '18 at 13:12