tags:

views:

375

answers:

8

I have created a JAR file and I want run it on a client. I have a couple of questions:

  1. How can I convert the JAR file to an EXE file?
  2. How can I encrypt the JAR file's contents? The jar file could be extracted with WinRAR and the classes could be decompiled with any Java decompiler.
  3. How can I create a installer? My clients doesn't have any JVM and I don't want to ship JDK or JRE along, because they have big size.
+3  A: 

JSmooth is a application which will wrap your Jar in an exe

it also allows you to check if the correct version of JRE is available on the system you're deploying to

http://jsmooth.sourceforge.net/

Ganesh Shankar
A: 

refer this

HotTester
+1  A: 

Hi,

As for 1): I guess you can not. There may be tools out there, but you cannot do that with standard tools shipped with JDK, as it would destroy platform independance. (See other answers providing links to such 3rd party tools)

As for 3): Use InnoSetup to create the installer. Include JRE within setup and let InnoSetup install it on the fly.

Thorsten Dittmar
I can't really see platform independence as a requirement. You generally target an audience, not a platform. If they have standardized on an environment you could target AND test that.
extraneon
I meant that such a tool would not be shipped with JDK due to platform independance reasons. JDK ships tools to build and package apps for any platform on any platform.
Thorsten Dittmar
+4  A: 
  1. The first google hit: Java to Exe. It also explains what valid reasons are to do this, and when you should not.

  2. You can't really encrypt binaries as the machine has to understand them. That said, an optimized executable is very difficult to decompile, while plain class files are ease.

  3. If you have an exe there are installers enough.

extraneon
+2  A: 

You can't prevent decompilation. The best you can do is make it harder or more time-consuming to do so. As an answer to your question though, I believe you can use gcj to compile Java into EXEs.

icktoofay
+1 for pointing out the futility of trying to prevent reverse engineering.
Stephen C
+1  A: 

Hello, May be Excelsior JET will satisfy your needs.) IMHO very mature product.

ponkin
A: 

1) I have recently tried the program jarToExe and like it. Some features are:

  • free basic version or very cheap ($30) for 'enterprise'
  • ability to have windows task manager list your app's name instead of the default java.exe
  • extra obfuscation
  • runtime check that java is installed

2) You can make it harder to reverse engineer using proguard or other obfuscator

3) nsis is a very powerful, free scripting language to create windows installers. Good documentation on the site wiki and support on stack overflow as well.

brian_d