How to hide or encrypt contents of jar containing in Install4J - 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.

Related

Is there a way to ensure that the correct JAR file is called by the Install4J service wrapper?

We are using Install4J v9 and our application needs to run as a Windows service. When we have installed the application as a Windows service, we have the original jar file myApp.jar and the service wrapper myApp.exe (which is running our jar file as a service) in the installation directory.
How can we ensure that our jar myApp.jar file is called by the service wrapper myApp.exe and not a substituted, fraudulent jar file?
I am wondering if jar signing would work, but how could install4j validate this signature?
install4j has no functionality to validate signatures of JAR files for inclusion in the classpath.
However, if an attacker can modify your JAR file, they can also modify your .exe file, so adding protection to the .exe against modification of the JAR file would not make anything safer.

Install4J - hide .jar file from installation directory?

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.

NetBeans Include External JAR in Export to Zip

I have a NetBeans project that uses the GSON library. I've tried including the GSON.jar file without requiring future users to separately download it. However it doesn't seem to work. The project looks for the file from the relative path of my computer so the file isn't found on another user's computer. Is there a way to include GSON.jar and "Export to Zip" and keep the reference in the project itself? I'm lost!
Thank you
Exporting a Project to ZIP zips up the project folder only, and not anything outside of the folder, including dependencies. If you include the GSON.jar file in the project folder, then the JAR file will be included in the .ZIP file. It's a good practice anyway since NetBeans will use a relative classpath and thus if you move the project itself NetBeans won't give you an error message when loading the project.

How exlude properties when building executable jar in Eclipse?

This question has been covered here before, but the only solutions I could find were in relation to a project using Ant or Maven. I am using neither. Here is the situation:
I have some application parameters in a properties file. This file is located in my Eclipse project (but in the src folder) and used when I run the application from Eclipse. In addition, I would like the application to also run as an executable jar file, in which case the user can provide the name of a properties file to use in a command line parameters.
The problem now is that the properties file from the project is always packaged into the executable jar and therefore the user is not able to easily modify the properties (yes, I know that (s)he could unzip the jar, but I want to avoid the extra steps).
How can I prevent the properties from being packages into the executable jar file?
Cheers,
Martin
Create a executable jar without properties file in it. Place both jar and properties file in a folder. Now add little code in your main program which should look for a properties file in the same folder and get the complete path of it. And then you can do something like this
System.getProperties().load(new FileInputStream(completepath));
So now your properties will be loaded into system properties with out affecting the actual system properties. You can access your properties by System.getProperty("Propertyname");
Hope this helps. Let me know if you have more questions.

How to Copy Files on War Start

I have a number for Word Docs and PDFs that need to be copied to a file storage on start of my Grails app.
I figured I can just leverage BootStrap.groovy to check for existing files then copy if none found. However, I don't know the best practice of including the files into the WAR file.
How can I copy these files?
I don't know if it is a best practice, however we have all our external files into web-app directory. i.e. We have directories reports and pdf besides css and images directories. All that files are package and deploy into war file.