You are here

How does one turn an executable JAR into a PA.c app with the Launcher?

10 posts / 0 new
Last post
Augi
Offline
Last seen: 10 years 1 month ago
Joined: 2009-04-04 14:15
How does one turn an executable JAR into a PA.c app with the Launcher?

As a start I wanted to turn an executable Java JAR into a portable app. I've received permission from the creators, and the app itself is open source.

The JAR doesn't seem to create any registry settings. It creates a .SETTINGS file after the first use, and a .LOG after every puzzle you solve, and both of these files reside in the same directory as the JAR. For simplicity (or what I think is simplicity's sake), I assume one has Java Portable and Java Portable Launcher available (as if they were installed via the PA.c Menu).

I'm stumped. I've tried playing with the Launcher INI settings enabling Java, configuring the working directy to that of the JAR, telling it the executable is JavaPortableLauncher, etc. Nothing seems to work. I've made simple experiments using BAT scripts to pass the JAR name to the JavaPortableLauncher.exe to no avail. Obviously I don't know the commands to open files.

What am I doing wrong? Can anyone point to some documentation on how to pass commands through Java Portable Launcher?

I'll post some of my first attempt INIs at a later date.

** Update 1 **
I've successfully made a launcher.ini. This requires jPortable to be installed via the PA.c Menu. mc4d.props is a settings file created in the directory with the JAR, and it is moved to the \Data folder at shutdown. Another file which can be created to save one's progress is the MagicCube4D.log, by default saved to the system's desktop. This file is also stored in \Data and replaced at start. These files can be deleted to have a clean start up of MC4DP.
I am having problems using the regshot utility to prove that my MC4DP leaves no other traces in the registry. I will research the forums for help on that matter.

** Update 2 **
Thanks to Chris Morgan for pointing out I needed an = in my -D switch.

[FilesMove]
MagicCube4D.log=%USERPROFILE%\Desktop
mc4d.props=%PAL:AppDir%\mc4d-4.0.180

[Activate]
Java=require

[Launch]
ProgramExecutable=javaw.exe
CommandLineArguments='-jar "%PAL:AppDir%\mc4d-4.0.180\mc4d-4.0.180.jar" -Duser.home="%PAL:DataDir%\Java"'

[Use <pre> for blocks, not <code> - mod Chris]

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
PortableApps.com Launcher

When making a portable app, you should use the PortableApps.com Launcher only. You can't depend on the Java Portable Launcher; it's designed for end-user use, not distribution. The PortableApps.com Launcher is entirely separate from the Java Portable Launcher.

Make sure you go through the section on Java apps. It's fairly complete. There are also some examples in development of Java apps using PAL; I've got links to my own apps and indicate the Java ones at http://chrismorgan.info/#portableapps-applications.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Augi
Offline
Last seen: 10 years 1 month ago
Joined: 2009-04-04 14:15
Does not work

Unfortunately the program itself is not an EXE. It is a JAR that runs with Java.

When you need to launch a Java application with java.exe or (more commonly) javaw.exe, set [Activate]:Java to force and then you can set ProgramExecutable to java.exe or javaw.exe and it will be rewritten to the path to that Java binary.

I tried following this and it still does not open.

Limits are for people with no imagination.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
Follow the instructions

Follow the instructions about working out what execution string you need in the Launch4J section.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Augi
Offline
Last seen: 10 years 1 month ago
Joined: 2009-04-04 14:15
A crude, and failed, first attempt

Not that anyone was dying to see this created other than me, but I was ill with a double-whammy ear infection turned upper respiratory infection, knocking me out for most of November.

[Activate]
Java=require

[Launch]
AppName=Magic Cube 4D
ProgramExecutable=javaw.exe
CommandLineArguments=-Duser.home="%PAL:DataDir%" -jar="%PAL:AppDir%\mc4d-4.0.180\mc4d-4.0.180.jar"

A failed first attempt. I generated blank icon files for the PA.cLG and filled in all I figured was necessary for the appinfo.ini.

I've tried adding single quotes around the entire CommandLineArguments string. I've also directed to javaw.exe, however when I launch MC4DP launcher, it fails with a path error message at start up. As it sits now I can see MC4DP launching, starting javaw.exe as a subprocess, but then shutting down.

What am I still doing wrong?

Limits are for people with no imagination.

vf2nsr
vf2nsr's picture
Offline
Last seen: 7 years 6 months ago
Developer
Joined: 2010-02-13 17:10
This was my file

for Java ScientificCalculator not sure if it will help

[Launch]
ProgramExecutable=javaw.exe
CommandLineArguments=-jar %PAL:AppDir%\jscicalc\jscicalc2-0.3.jar
[Activate]
Java=Require

“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” Dr. Seuss

Augi
Offline
Last seen: 10 years 1 month ago
Joined: 2009-04-04 14:15
Thank you!

That worked. This is what happens when a mechanical engineer dabbles in software. I would never have thought to drop the -Duser.home, and probably have never noticed that I added equal signs between the switches and directories.

From here it's going to be a breeze to convert all my favorite java games to PA.c, and then test to make sure they don't leave anything behind.

Limits are for people with no imagination.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
Keep -Duser.home

Keep -Duser.home; it was the = in -jar that was the only problem.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Augi
Offline
Last seen: 10 years 1 month ago
Joined: 2009-04-04 14:15
Update 1

I've successfully made a launcher.ini. This requires jPortable to be installed via the PA.c Menu. mc4d.props is a settings file created in the directory with the JAR, and it is moved to the \Data folder at shutdown. Another file which can be created to save one's progress is the MagicCube4D.log, by default saved to the system's desktop. This file is also stored in \Data and replaced at start. These files can be deleted to have a clean start up of MC4DP.
I am having problems using the regshot utility to prove that my MC4DP leaves no other traces in the registry. I will research the forums for help on that matter.
[FilesMove]
MagicCube4D.log=%USERPROFILE%\Desktop
mc4d.props=%PAL:AppDir%\mc4d-4.0.180

[Activate]
Java=require

[Launch]
ProgramExecutable=javaw.exe
CommandLineArguments='-jar "%PAL:AppDir%\mc4d-4.0.180\mc4d-4.0.180.jar" -Duser.home "%PAL:DataDir%\Java"'

Limits are for people with no imagination.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 8 years 10 months ago
Joined: 2007-04-15 21:08
= in -D

You should have = in the -D parameter, just not in the -jar parameter; -Duser.home="%PAL:DataDir%\Java"

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Log in or register to post comments