Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Launch4J  (Read 3994 times)
0 Members and 1 Guest are viewing this topic.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Posted 2013-11-22 20:11:20 »

I'm trying to turn a jar into an exe using launch4j but I'm useless with these tools.
I have the program running in a small window however I normally make the program run full screen with the following:
Quote
>java -jar -Dsun.java2d.noddraw=true AlienSwarm.jar FULLSCREEN

How do I do this with launch4j?

How can I test that the program will run fine on a PC with no java (or an old java) installed?

Many thanks

Mike

Arcade swarm
Board Chess - Checkers - Othello
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2013-11-22 21:15:14 »

So let me get this straight, you want to run a java program without java installed? You know that Launch4J just creates an executable version of the Jar file so that your program is easier to distribute. I don't understand why you think you can run a Java program without a JRE installed, unless I'm missing something here.

Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #2 - Posted 2013-11-22 21:39:29 »

How do I do this with launch4j?

Have you tried looking at the docs? Both the "<opt>" tag section as well as the "Additional JVM options at runtime" section would seem to be what you're looking for.

Edit: Forgot to mention the "<cmdLine>" section which should be what you need to pass the "FULLSCREEN" flag.

How can I test that the program will run fine on a PC with no java (or an old java) installed?

Uninstall Java or get a machine with no Java on it and see what happens when you run the .exe. The "<jre>" section of the docs page talks about the different options you have which include: use a bundled JRE that you include with your application, search for an installed system JRE that meets a min/max version requirement, or throw an error and display the Java download page in the user's browser. I'd make it easy on your end users, and go with the first option.

If you don't have a second machine, you can always try something like VirtualBox. Create a new virtual drive and do a fresh OS install without Java, then fire up your installer from inside the image. The run time performance will be reduced, but it should allow you to see how the installer will react to different scenarios without messing with your actual OS.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #3 - Posted 2013-11-22 22:26:04 »

you could also give JarSplice a try, should be a lot more user friendly to use and you can easily include vm parameters.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #4 - Posted 2013-11-23 12:03:46 »

unless I'm missing something here.
I believe you're missing something Cheesy I'm just trying to supply an arcade game in the same vein as the old shot-them-up arcade games. Less technical users on PC don't like having Java on their PC and prefer to just run a simple exe. Those installing the game into arcade cabinets have probably never heard of Java and they'd never want to see a popup telling them it's time to update the Java runtime etc. There's also the current security scares. I know the "dream" was that you could simply trust Java programs and simply run them but the reality (for me) appears very different to end users and they seem to prefer an exe.

Have you tried looking at the docs? Both the "<opt>" tag section as well as the "Additional JVM options at runtime" section would seem to be what you're looking for.

Edit: Forgot to mention the "<cmdLine>" section which should be what you need to pass the "FULLSCREEN" flag.
Didn't see docs though I did try what I thought might be the help but it just told me the version of the program. Actually I've looked through the docs and I suspect I'm too stupid to understand them  Cry

Uninstall Java or get a machine with no Java on it and see what happens when you run the .exe. The "<jre>" section of the docs page talks about the different options you have which include: use a bundled JRE that you include with your application, search for an installed system JRE that meets a min/max version requirement, or throw an error and display the Java download page in the user's browser. I'd make it easy on your end users, and go with the first option.
I'll see if I can work out how to do this - it's a bit of a shame it doesn't default to this and use whatever environment variables there are to find the jre itself.

you could also give JarSplice a try, should be a lot more user friendly to use and you can easily include vm parameters.
I'll have a look at this, thanks.

Will either tool (launch4J or JarSplice) allow you to pass run time parameters?
Quote
MyProg.exe FULLSCREEN MAME_KEYS

Thanks for the immediate responses by the way.

Arcade swarm
Board Chess - Checkers - Othello
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #5 - Posted 2013-11-24 06:10:31 »

It looks like their graphical front end should make the options easy to set.



If that doesn't work, try editing the project's XML file directly.

To answer your question about command line parameters, yes. Look at the 6th text input box down on the above screenshot of launch4j.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #6 - Posted 2013-12-11 09:42:41 »

I hate coming back to this simply because it makes me feel like a fool Angry
I simply want my exe to run whether the user has Java, an old Java or no Java at all.
I assume I need to bundle the Java inside the exe.
There's a field on the JRE tab called "Bundled JRE path" but what do I enter?
Do I need to zip anything or place anything inside my jar or directory?
Do I need to specify a minimum version or anything?

Mike

PS I've been through the docs

Arcade swarm
Board Chess - Checkers - Othello
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #7 - Posted 2013-12-11 11:25:31 »

I'm afraid I don't use NetBeans etc.
If I went down that path then I'd just be back again with a new bunch of questions.
At least on this path I'm only stuck on one (hopefully small) thing.

Arcade swarm
Board Chess - Checkers - Othello
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #8 - Posted 2013-12-11 15:46:05 »

I hate coming back to this simply because it makes me feel like a fool Angry

There's no foolishness in asking for assistance in figuring something out. Cool

I simply want my exe to run whether the user has Java, an old Java or no Java at all.
I assume I need to bundle the Java inside the exe.

I think this is where some of the confusion is coming from. Let's break this down into two steps.

The first step is getting the JRE onto the users computer. For this, you'll need to download a tool suck as NSIS or Inno Setup. Both of these packages are free and allow you to create Windows installers; Inno Setup is the tool that NetBeans, as mentioned by Tom, uses to create its installers. This will allow you to bundle up your executable and supporting files created by Launch4J along with a standalone JRE and any other related files into one executable that your users will download and run in order to get all the needed components onto their PC.

Now that we have the solution for how to reliably get a JRE onto the end user's computer, we can concentrate on the second step, the settings in Launch4J. At some point while creating the installer that I just mentioned, you'll have to decide on a directory structure for your application.

Let's assume it looks like this:
1  
2  
3  
4  
5  
<MyApplication>
    |____<JRE>
    |____<bin>
    |   |____MyLaunch4J.exe
    |____<etc>

You will need to enter in a relative path to the JRE directory in Launch4J's "Bundled JRE Path" field. Using our example structure above, the path would be (without the quotes) "..\JRE" since the JRE folder is one level up from where the executable file resides. If the executable was directly in the "MyApplication" folder then the path would be ".\JRE". Hopefully this gets you closer to getting everything packaged up for distribution. If you have any other questions, feel free to ask.

Quick last note. Obtaining a "standalone JRE" is as easy as copying your JRE folder from your "Program Files" to your applications directory structure. This means that the JRE you've used during development will be the same one your end users receive. One less compatibility issue to worry about.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #9 - Posted 2013-12-11 15:56:47 »

Thanks for replying so soon!

There's no foolishness in asking for assistance in figuring something out. Cool
No, but if someone just can't understand the answers then I'd start to have my suspicions  Wink

The first step is getting the JRE onto the users computer. For this, you'll need to download a tool suck as NSIS or Inno Setup. Both of these packages are free and allow you to create Windows installers; Inno Setup is the tool that NetBeans, as mentioned by Tom, uses to create its installers. This will allow you to bundle up your executable and supporting files created by Launch4J along with a standalone JRE and any other related files into one executable that your users will download and run in order to get all the needed components onto their PC.
I thought the idea was to bundle the java.exe along with your jar so it didn't need to install java? I don't know for certain but I'm pretty sure my target audience don't want Java on their PC's as the PC's -their PC's are running inside gaming cabinets with perhaps a few arcade controls for input - having a java popup telling them to get the latest security update would just destroy the whole illusion of having a dedicated arcade cabinet. I just want an exe the user can run.

Arcade swarm
Board Chess - Checkers - Othello
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #10 - Posted 2013-12-11 16:33:00 »

I thought the idea was to bundle the java.exe along with your jar so it didn't need to install java? I don't know for certain but I'm pretty sure my target audience don't want Java on their PC's as the PC's -their PC's are running inside gaming cabinets with perhaps a few arcade controls for input - having a java popup telling them to get the latest security update would just destroy the whole illusion of having a dedicated arcade cabinet. I just want an exe the user can run.

You have the right thought. The JRE that's distributed with your application isn't technically "installed" by the Windows' definition of installed. It doesn't modify the registry, it doesn't attempt to hook into the browser, it doesn't modify JAVA_HOME, and it doesn't install the Java update scheduler. Java is a lot more independent of the OS than most people think. That being said, your users will not be notified of Java updates or prompted to download anything when using the previously mentioned technique, at least not by the JRE you distribute with your application. It's just as seamless as any native application to the end user.

We actually use standalone JRE installations where I work when we have an application to deploy that requires a newer version of the JRE than what the user has on their system, but updating the system installed JRE isn't feasible due to IT department restrictions. PrinceC also uses standalone JREs for Puppy Games releases if I recall correctly.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #11 - Posted 2013-12-12 14:13:24 »

It's taken me about a month to realise that I can't get launch4J to work.
I'm guessing it will take me another month of perpetual trial, error and failure to play with NSIS and Inno.
It's a bit depressing  Cry
It's a shame that launch4J can't just do this - I thought the whole point of the tool was to produce an executable exe.

Arcade swarm
Board Chess - Checkers - Othello
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #12 - Posted 2013-12-12 15:02:02 »

Well, deployment is as much a part of development as any other step in the process and if you want other people to use your creations, then you'll have to add it to your stack of knowledge at some point.

Launch4J does exactly as advertised; it creates an executable wrapper for your jar file. While it offers some options to make it easier to find or install a JRE on an end users computer, it's not the main focus. Even if it was, you don't want to bind Java to the OS by using an Oracle/OpenJDK installer, especially in the case of a stand alone game cabinet as you describe.

Let me ask you this, how big of a project are you dealing with here? Does it require anything beyond essentially sticking your game in a folder on the computer, or do you want the full "proper" Windows installation flow including entries in Add/Remove programs? If it's the first case, then you can probably get away with skipping over NSIS like tools and use something as simple as WinZip to create a self extracting archive for distribution.

If you can show me how you want your final directory structure to look, I can try creating a Launch4J project that will work with your structure, then I'll send the configuration file back to you along with a Zip file that includes the directory structure along with a standalone JRE already in place. You'd still have to build the final executable yourself (unless you want to actually send the files in which case you'd get back a finished package) but you should be able to see how everything relates in L4J.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #13 - Posted 2013-12-12 18:30:10 »

That's well above the normal call of duty but I'm certainly not going to stop you Smiley

I don't need an installer, just an exe is fine.
I'll release it with a few batch files that call the exe with different parameters depending on whether they're installing the program in a cabinet or just via PC.
I just have a single directory and everything is stuffed into it at present. Does that count as a directory structure?
I know it's not a pretty way of doing things but everything was hidden in the jar so I didn't spend the time to set up the directories.

Mike

My current xml file looks like this if that helps:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.jar</jar>
  <outfile>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.exe</outfile>
  <errTitle></errTitle>
  <cmdLine>-Dsun.java2d.noddraw=true</cmdLine>
  <chdir>.</chdir>
  <priority>high</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
 <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <manifest></manifest>
  <icon>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.ico</icon>
  <jre>
    <path>./jre7/bin/</path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
  </jre>
</launch4jConfig>


Arcade swarm
Board Chess - Checkers - Othello
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #14 - Posted 2013-12-12 18:48:49 »

That's well above the normal call of duty but I'm certainly not going to stop you Smiley

Well, I hate to see someone get all the way through the process of development only to be stymied by the deployment phase. Give me a little while to get everything together (I'm currently going back and forth from my PC to other parts of the office atm), and we'll see if we can't get you back on track in short order. Smiley

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #15 - Posted 2013-12-12 20:22:15 »

Alright, I think we have you set. Grin Here is a link to a self extracting zip version of your game, and here is a link to a regular zip version of your game. The self extractor was created with 7zip. While this was a pretty straightforward build, you'll have to give me a little time to get a summary of the steps posted since I'm about to head out to lunch; I just didn't want to leave you hanging when it came to the final product.

These were built with the latest version of the game from your web page and includes a bundled Java7 JRE. I also took the liberty of editing your batch files to work with the .exe version of your game. Give it a try out an let me know if anything is off. I've tested it here a few times with no issues, but one machine is hardly definitive proof.

I'll include the configuration file that was generated by Launch4J for your reference. I tried to keep the directory structure as close as possible to what it looked like you had.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.jar</jar>
  <outfile>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir></chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
 <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <manifest></manifest>
  <icon>E:\Dropbox\Projects\AlienSwarm\AlienSwarm.ico</icon>
  <jre>
    <path>.\jre7</path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <minVersion></minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>preferJre</jdkPreference>
    <opt>-Dsun.java2d.noddraw=true</opt>
  </jre>
</launch4jConfig>


I'll be back in a while to post the steps I went trough so you can reference them in the future. Cool

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline mike_bike_kite

Senior Member


Medals: 1
Projects: 2



« Reply #16 - Posted 2013-12-12 21:06:28 »

Oh bugger - I haven't released the latest version of the game for a month or two.
Shall I PM the jar or wait for the instructions?
Mike

PS I PM'ed the jar anyway



Arcade swarm
Board Chess - Checkers - Othello
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #17 - Posted 2013-12-12 21:20:18 »

Oh bugger - I haven't released the latest version of the game for a month or two.
Shall I PM the jar or wait for the instructions?
Mike

PS I PM'ed the jar anyway

Not a biggie. It will probably be a little while longer before I get a chance to post the instructions, so feel free to send an updated version of the .jar (I didn't see it in my messages here, so it may not have gone through yet). You can always email it to me redacted if that makes it easier. Once I get it, I should be able to get it back to you within a few minutes (uploading to my host takes the most time). Wink

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline ags1

JGO Ninja


Medals: 62
Projects: 3
Exp: 5 years


Make code not war!


« Reply #18 - Posted 2013-12-12 21:58:44 »

Er, maybe edit out your email address from the previous post ^^^ and PM it instead?

Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #19 - Posted 2013-12-12 22:04:50 »

Ah, thanks to a cancelled meeting, it looks like I have more time than I thought. Cool

How to create an executable application from a runnable jar file with Launch4J
  • Create a project folder for your files. I recommend making two sub-folders, the first called Input will hold all of the needed files for your Launch4J project, namely your main .jar file, your Launch4J configuration file, and your applications .ico file (if desired). Call the second folder Output; this will hold the directory structure for our final distribution.
  • Copy your .jar file and optionally your .ico file into the Input folder. You should also go ahead and copy any files needed by your application into the Output folder at this point. This will include any external lib folder/.jar files that your application uses, any native files that your application uses, and your standalone JRE directory.
  • Fire up Launch4J and fill in the following fields on the "Basic" tab:
    • Output file: This should be set to <Your Project Folder>\Output\<Your .exe file name>
    • Jar: This should be set to <Your Project Folder>\Input\<Your .jar file name>
    • Icon: Optional, this should be set to <Your Project Folder>\Input\<Your .ico file name>
  • Now switch to the "JRE" tab and fill in the following:
    • Bundled JRE path: This is the relative path of your jre to the .exe file that Launch4J produces. Since your application has the .exe file and the jre folder in the same directory, it should look like .\<JRE folder name>
    • JVM Options: Any flags that you would usually pass to the JVM go here (for example: -Dsun.java2d.noddraw=true)
  • At this point you're ready to click on the build wrapper button in Launch4J (It's in the top toolbar and looks like a gear). You will be prompted to save your configuration file at this point if you havent already. I advise saving it as <Your Project Folder>\Input\<Your project name .xml> in case you need to make changes in the future. Once the file is saved, Launch4J should spit out your .exe file in the directory yu specified earlier.
  • All that's left is to make a folder named after your application (ie: AlienSwarm), copy all of the files from the <Your Project Folder>\Output folder to the new folder, then try out the executable. If all went well, your application should b up and running. If you want to make sure that it's using the JRE in the current folder, you can try renaming the JRE folder and firing up the application again. In this instance we're hoping to see an error message appear. Now that you're satisfied it's using the correct JRE folder, rename it to the previous name, open the application again to verify the error dialog no longer appears, and you're done.
  • Bonus Step: Download a copy of 7-Zip (it's free) and install it. Now right click on your applications distribution folder and choose 7-Zip>Add to archive. On the "Add to Archive" window that appears, set the "Archive format" option to "7z", check the option on he right that says "Create SFX archive", then click the ok button. After a few moments 7-Zip will complete, and you will have a self extracting archive that's ready to distribute to Windows users. If you just want a plain .zip archive, do the same steps except set the "Archive format" option to "zip" and leave the "Create SFX archive" option unchecked (it should be grayed out once you change the archive format anyway).

Give the instructions a shot and let me know if you have any issues. My "how to" writing skills tend to range from "craptastic" all the way up to "not so good", so if you have any questions, I will be more than happy to clarify.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #20 - Posted 2013-12-12 22:08:52 »

Er, maybe edit out your email address from the previous post ^^^ and PM it instead?

Sound advice. In all honesty though, I've used that email for anything and everything under the sun, so I'm not too worried about it getting around. Good looking out though. Cool

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!