Filehoo free downloads

 Debuggers-Decompilers-Dissasemblers Downloads


Jelude

Last Updated:10/8/2007 10:52:03 AM
Downloads :627 Add Reviews


Download Now

Version: 1.0, Size: 249 KB Report Broken
User Rating:, License: Free

Jelude description
Jelude is a short NSIS script designed to allow JAR files to be wrapped in an EXE file so they can be made distributable to Windows users. The main advantage over distributing JAR files alone is that the end user is prompted when a Java Runtime ...

What is Jelude?

Jelude is a short NSIS script designed to allow JAR files to be wrapped in an EXE file so they can be made distributable to Windows users. The main advantage over distributing JAR files alone is that the end user is prompted when a Java Runtime Environment (JRE) is not found on the computer and an option is provided to download it.

Other features include:

  • A single distributable with no floating files.
  • Support for multiple JAR files.
  • Runtime parameters are transferred to the Java application.
  • An optional splash screen can be shown at startup.
  • Free

Note that Jelude does not convert your actual Java code into a native application. Also, Jelude does not replace the role of a Java Virtual Machine (JVM).

How do I use Jelude?

  1. First download the script and NSIS compiler.

  2. Then open the script file using a text editor (like Notepad) and edit the first 2 lines to specify your application name and JAR filename. i.e.,

    !define APPNAME "Synergy Easter Egg Demo"
    !define JARFILE "Egglet.jar"

    A screenshot of the script file opened using notepad.

  3. Then compile the script using the NSIS compiler by running the following instruction at the command prompt. (In the same way you compile Java code):

    makensis.exe script.nsi

    A screenshot of the command prompt entering the said commands.

  4. An EXE file named launch.exe should be produced in the same directory. You can now distribute that EXE file to anyone.

How does it work?

When you execute the compiled program, the program will search the system registry and environment variables for a JRE and if it exists, it will extract the JAR file to a temporary folder and execute it with the JRE. Any parameters sent to the EXE would be passed along to the JAR file. The program will also register a mutex with Windows for 5 seconds to prevent the same program from being executed multiple times if, for example, the user double clicks on the icon several times while the JVM is still loading. If a splash screen is specified, it will be displayed for 4 seconds.

However, if no JRE is found, it will display an error message.

A screenshot of the popup dialog shown when a Java Runtime Environment is not found.

If the user clicks on the "Yes" button on the error message dialog box, they would be directed to the Sun website to download the JRE. If the user clicks "no", the application exits.

License?

This script is license free and is considered a part of the public domain. Feel free to use it or add on to it. The NSIS compiler, however, is distributed by Nullsoft and is subject to their license.

 

Here is an inline copy of the script in it's entirety with nice formatting:

;--------- CONFIGURATION ---------

!define APPNAME "Synergy Easter Egg Demo"
!define JARFILE "Egglet.jar"

;Uncomment the next line to specify an icon for the EXE.
;Icon "test.ico"

;Uncomment the next line to specify a splash screen bitmap.
;!define SPLASH_IMAGE "splash.bmp"

;---------------------------------

Name "Jelude"
Caption "${APPNAME}"
OutFile "launch.exe"

SilentInstall silent
XPStyle on

!addplugindir .

Section ""
  System::Call "kernel32::CreateMutexA(i 0, i 0, t 'jelude') i .r1 ?e"
  Pop $R0
  StrCmp $R0 0 +2
  Quit

  ClearErrors
  ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
  ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R0" "JavaHome"
  IfErrors 0 FoundVM

  ClearErrors
  ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
  ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$R0" "JavaHome"
  IfErrors 0 FoundVM

  ClearErrors
  ReadEnvStr $R0 "JAVA_HOME"
  IfErrors NotFound 0

  FoundVM:
  StrCpy $R0 "$R0\bin\javaw.exe"
  IfFileExists $R0 0 NotFound

  StrCpy $R1 ""
  Call GetParameters
  Pop $R1

  SetOverwrite ifdiff
  SetOutPath $TEMP
  File "${JARFILE}"
  StrCpy $R0 '$R0 -jar "${JARFILE}" $R1'
  Exec "$R0"

  !ifdef SPLASH_IMAGE
    SetOutPath $TEMP
    File /oname=spltmp.bmp "${SPLASH_IMAGE}"
    Splash::show 4000 "$TEMP\spltmp"
    Delete "$TEMP\spltmp.bmp"
  !endif

  Sleep 5000
  Quit

  NotFound:
  Sleep 800
  MessageBox MB_ICONEXCLAMATION|MB_YESNO           'Could not find a Java Runtime Environment installed on your computer.           $\nWithout it you cannot run "${APPNAME}".           $\n$\nWould you like to visit the Java website to download it?'           IDNO +2
  ExecShell open "http://java.sun.com/getjava"
  Quit
SectionEnd

Function GetParameters
  Push $R0
  Push $R1
  Push $R2
  StrCpy $R0 $CMDLINE 1
  StrCpy $R1 '"'
  StrCpy $R2 1
  StrCmp $R0 '"' loop
  StrCpy $R1 ' '
  loop:
    StrCpy $R0 $CMDLINE 1 $R2
    StrCmp $R0 $R1 loop2
    StrCmp $R0 "" loop2
    IntOp $R2 $R2 + 1
    Goto loop
  loop2:
    IntOp $R2 $R2 + 1
    StrCpy $R0 $CMDLINE 1 $R2
    StrCmp $R0 " " loop2
  StrCpy $R0 $CMDLINE "" $R2
  Pop $R2
  Pop $R1
  Exch $R0
FunctionEnd

Why did I create Jelude?

It's because I wanted to experiment with NSIS before I do any real work with it. NSIS stands for, Nullsoft Scriptable Installation System, and is created by the same people who brought you, Winamp. Since I am a Java programmer, I decided to create a JAR distribution program.

The script is indeed really short!?

Yes it is. It shows how powerful NSIS can be with just a few lines of code. (See below for an inline version of the NSIS script.) I decided to keep the script short but simple rather than long but powerful because that was what I wanted. As long as it gets it's job done. Note that because of this, it will only run the JRE if it is version 1.2.X and above and was produced by Sun. If you want fine tuned version checking, you will have to do it from within your Java application.

Note: Jelude uses the "System" plugin by Nik Medved, the "Splash" plugin by Justin & Amir Szekely and the "GetParameters" code by Sunjammer.

Why name such a short program?

I felt that quite a few Java programmers could benefit from this tool so I decided to give it a name so that others could find it easily via search engines. The name Jelude comes from the letter "J" and the word "elude" which is meant to show how easily Java applications could be designed to mimic native Windows applications.

How can I show the text console for my application?

You can show the text console by editing the following line in the script to use java.exe instead of javaw.exe to launch the Java application:

StrCpy $R0 "$R0\bin\javaw.exe"

change to

StrCpy $R0 "$R0\bin\java.exe"

How can I specify more than one JAR file?

If you want to specify more JAR files to extract, simply edit the following line to include a reference to your jar files.

SetOutPath $TEMP
File "${JARFILE}"
File "second.jar"
File "third.jar"

StrCpy $R0 '$R0 -jar "${JARFILE}" $R1'

The additional files will automatically be included when you compile the script. If you do decide to use multiple JAR files, don't forget to include the classpath information within the main JAR file's MANIFEST file. For more information on how to do this, read the JAR file documentation below.

How can I modify where the JAR file is extracted?

By default, the JAR file is extracted to the computer's default temporary folder. This is usually located in "C:\Windows\Temp" and is represented by the symbolic constant, "$TEMP". You can change the output folder to the folder where the EXE file is currently residing by editing the following line in the script:

SetOutPath $TEMP

change to

SetOutPath $EXEDIR

How can I locate the directory of the EXE file in the Java application?

You can explicitly pass the EXE file's directory information to the Java application by using Java's System Properties facility. You can do this by editing the following line in the script:

StrCpy $R0 '$R0 -jar "${JARFILE}" $R1'

change to

StrCpy $R0 '$R0 -Dexe.dir="$EXEDIR" -jar "${JARFILE}" $R1'

Then when you need to locate the directory information inside your Java application, simply call, System.getProperty("exe.dir") which returns a String. This feature may be useful if the EXE file is accompanied with other files in the same directory.

How can I make it delete the JAR file after it exits?

You can specify that the EXE file deletes the JAR file from the temporary folder after it exits, by editing the following line in the script. If left unchanged, the default configuration is to leave the JAR file in the temporary folder so that on subsequent launches the JAR does not have to be extracted everytime.

Exec "$R0"

change to

ExecWait "$R0"
Delete "${JARFILE}"

If you do modify the code, the EXE file will then persist in memory until the Java application exits whereafter the EXE file will delete the JAR file and exit itself.

It is important to note that the splash screen is shown after the call to start the JVM. If you make the above changes, the program will pause until the JVM exits which therefore prevents the splash screen from being shown beforehand.

What are JAR files?

JAR files are the distribution format recommended for Java applications. You can use the JAR tool provided by Sun to store all your CLASS files, image files and data files into one JAR file for easy transportation. JAR files are by default compressed files. For more information and instructions for producing and using JAR files, read the JAR Tutorial. 

 

Add Review for Jelude

Subject *  
Email *  
Nick Name *    
 Image Confirm*  Refresh
 
Your Reviews (Max 2000 Chars) *

 

 
Home - Contact - Archive - Submit Download
 
©2007 filehoo.com