Install4J - hide .jar file from installation directory? - install4j

I am currently working on turning my java application into a windows installer, converting the .jar into and .exe file.
Have chosen Install4J because of the ability to bundle JDK with the application, as well as recognizing previous installations when deploying updates.
Only problem I have, is the fact that the jar file for the application, is saved in the installation directory as well.
Does anyone know how to fix this? I don't want the original jar file in the directory, just the converted exe file.

The .exe file is just a launcher for the JVM, it does not contain natively compiled Java code.
The best way to protect your code is to use an obfuscator like ProGuard.

Related

How to hide or encrypt contents of jar containing in Install4J

I used install4J and created an exe out of jar file. But here the issue is, the jar files needs to be in the installation directory, otherwise the exe wont work if I share that exe to outside world.
Is there a way to encrypt or hide contents of jar file in Install4j?
install4j does not offer features to encrypt or hide JAR files. These strategies aslo make limited sense because you have to pass the unencrypted JAR files to the JVM at some point and then it's quite easy to extract them.
Use an obfuscator like proguard instead.

Install4j - embedding jar into generated launcher

I have 'generated launcher' which executes my java application - aplication is in jar package.
Is there any way how to include jar into generated EXE file(launcher)? Customer wants to have only exe file, not jar in installed folder. Is there any way how to do it?
There is no way to do that with install4j. You can do it with exe4j, by using the "JAR in EXE" mode and add the generated executable to the distribution tree instead of using the generated launcher. This only works for Windows, though.

JNA finds library running in Eclipse but not when a built JAR file

I am writing a program which needs to use a .dll file. When my program starts up, the following code is executed:
public static void main(String[] args)
{
String dLLURL = "C:/Program Files (x86)/Location of DLL";
System.setProperty("jna.library.path", dLLURL);
System.setProperty("jna.debug_load", "true");
System.setProperty("jna.debug_load.jna", "true");
Application.launch(args);
}
I then execute
DllInterface dllinterface = (DllInterface) Native.loadLibrary( "dllName.dll", DllInterface.class);
...which loads the correct dll and allows me to use it. JNA outputs the following (this time using the actual name/path of the DLL):
Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader#e2f2a for /com/sun/jna/win32-x86/jnidispatch.dll
Found library resource at jar:file:/C:/Users/bengs_000/Downloads/jna.jar!/com/sun/jna/win32-x86/jnidispatch.dll
Trying C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna2314341730536889248.dll
Found jnidispatch at C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna2314341730536889248.dll
Looking for library 'RailDriver.dll'
Adding paths from jna.library.path: C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Found library 'RailDriver.dll' at C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
This is what happens when I run the program in Eclipse IDE. It works just fine!
However, when I build/run the program as a .jar, the application says the DLL cannot be found (despite looking in the correct location) and returns the following message:
Trying (via loadLibrary) jnidispatch
Looking in classpath from java.net.URLClassLoader#677327b6 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Found library resource at jar:rsrc:jna.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Trying C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna8530559464473818762.dll
Found jnidispatch at C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna8530559464473818762.dll
Looking for library 'RailDriver.dll'
Adding paths from jna.library.path: C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Adding system paths: []
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Looking for lib- prefix
Trying libRailDriver.dll
Looking in classpath from java.net.URLClassLoader#677327b6 for RailDriver.dll
There was an error finding your raildriver.dll file
As you can see, exactly the same path is taken to find the .dll file yet it works in Eclipse and not as a compiled .jar file!
Would you please be able to help me identify the problem? One thing to note is that the .dll file is stored within the 32bit section of Program Files, and my computer is 64bit. I am using Java 32bit to compile and run the program in Eclipse. Surely it should build the .jar with Java 32bit right?
I have found a solution!
The Background
I knew that the problem was related to the .dll I wanted to use being 32bit, and my computer being 64bit. In the Eclipse IDE, I was running the app using Java 32bit (I knew I should to this to ensure compatibility).
When running the .jar file, Java was defaulting to the 64bit version; different to how I was testing it in Eclipse.
The Solution
To force the user to use Java 32bit, you need to bundle the .jar into an .exe file. I used Launch4J to do this. There's a parameter in Launch4j which allows you to specify which systems of Java to use. This is located under the JRE tab in the "Search Options" section. By changing it to "32-bit only", the .jar file is launched under Java 32-bit, thus alleviating the problem!
I hope this might help some one!

install4j deploy no jar file

I'm new to install4j.
So I hope this question is easy to answer and not obvios.
I involved to an Java-development-project.
We decided to use install4j to create a nice installer for our customers.
Now i've got an install4j license and testing to create an installer.
I Use the install4j Launcher Wizard to make a .exe file out of my .jar file.
Now the Problem: If I remove the .jar file from the installer, the .exe file doesn't work anymore.
So the question: Is it possible to deploy with install4j an .exe file without the .jar file ?
WebStart is not an option in this project.
The .exe is just a launcher to start the JVM. Your Java code is not compiled into native code by install4j. If you want to protect your code, you have to use an obfuscator, for example yguard.
I think install4j can package the Jar inside the executable, as shown in this blog post:
http://blog.ej-technologies.com/2010/12/my-first-try-with-install4j-tutorial.html

Difference between adding library and .jar file in NetBeans?

I have a .jar file of LWUIT, and it's also in there in the NetBeans library.
When I add it as a .jar file my programs run good and when I add it as a library my output is not shown correctly. What's wrong with this?
When added as a library, LWUIT is only available for your application to compile against. I assume LWUIT is not already installed on whatever J2ME-enabled device/emulator you want to run your application.
When added to your application JAR file, LWUIT is also available for your application to run against. Your application JAR file is presumably significantly larger then.