How can I send my java application to a friend without having to send the entire project and being dependent on him having JDK? I'm aware of the .jar-file's existence, but I don't know how to proceed. I would like to be able to just send him the .jar-file or an executable file.
Any ideas?
Compile it to native code using a compiler such as http://en.wikipedia.org/wiki/GNU_Compiler_for_Java
Also, he doesn't need the JDK, just the JRE.
Did what #Barranka said regarding the dist folder, didn't know that worked until I read the readme file as #Barranka suggested.
So to quote what #Barranka said:
If you work with NetBeans, when you "build" your project, a dist
folder is generated, and your "packed" app is stored there. You can
send the contents of this folder. Read the "readme" file in that
folder. – Barranka
You can send the JAR file alone provided your program does not depend on other libraries. Assuming that there is a main() method and Main Class is configured in the JAR's manifest, the person can run it by Double Clicking (on windows) or use the command line
java -jar <jar_file_name>.jar
You cannot execute a Java application without a Java Virtual Machine, so you need one.
Your friend has to download a JRE/JDK, or you can provide it with your application directly as it (the JRE and your project in an archive) or provide it as a native compile code using GCJ or Excelsior Jet which will compile your application and a JRE.
As you can see the is no solution for your question, but there is one for your problem : ask your friend to download a JRE.
Related
I am trying to create an executable out of my JavaFX project that uses mysql-connector driver to connect to a local database. After i generate the JLink folder via the pom.xml file, when i run my application, the connection between the database and the app does not work (Running the application in the IDE makes everything work fine). I am using InteliJ as my IDE, MySQL for the database and i think the connector is a jar file without a module-info.jar file which is causing issues in JLink.
I did some digging and i found out that mysql-connector can not be added directly via Jlink. I've seen some workarounds (for example: moditect) but i still can't figure it out. Any help is greatly appreciated!
You can't use jlink to directly create an executable file if your application is not fully modular. However, you can use a combination of jdeps, jlink and jpackage to create an application bundle or an installer. You might want to have a look at this tutorial: https://github.com/dlemmermann/JPackageScriptFX
I finished writing a little tornadofx app in IntelliJ CE and now want to export it as a single file which can be downloaded and launched by users. For now it would be sufficient to provide a single jar file. But it would be also great to know on how to export a self contained installer for OSX, Windows and Linux. Unfortunately I don't know how to do any of that. Can you help?
Have a look at the FxLauncher project, which is also from the creator of tornadoFX. FXLauncher allows you to easily distribute your javafx/tornadoFX application. The project provides a maven-plugin which allows you to generate a self containing javafx/tornadoFX application that you then publish to a web-server or common directory (e.g an internal app in your company network). After that you can generate native installers for Linux, OSX and Windows. The installer itself will only install a small app, which will know the location of your web-serve or directory. On startup it will download the latest deployed version of you application and run it.
Additional links:
GitHub-project
Introduction screen cast
Customizing update ui
In case you want a single jar file, you can export it as a regular Java program (not the JavaFX option in IntelliJ). You do this by creating and building an artifact.
Go to the Project Structure window, and from there select Artifacts
Click the "+" icon to create a new artifact, and select JAR > From modules with dependencies...
Select the main class and press OK
And that's it, the artifact has been set up, now, to generate jar file, just go to Build > Build Artifacts menu, and select the newly-made artifact, and the IntelliJ will generate the jar file in the "out" directory.
Not sure if this is the best solution, but it's what I've been using, and it works for me.
So I have been working with the free version of JWrapper for some time now and have been quite pleased with the results; however, I have now purchased a license and would like to use it but I am unable to find the method with which to activate my JWrapper. I do not use the graphical interface version of JWrapper; rather I have created a xml installation file and pass that directly via commandline to JWrapper for building. Is there a special xml tag for specifying the license location? I was unable to find this information on JWrapper's homepage or support docs.
I received an answer from the support team. In order to use the license without using the JWrapperApp gui to build your application you will simply have to have the jwlicense.txt file in the same directory as your jwrapper.jar
After some tests it appears that the jwlicence.txt file must be in the current directory. So the best is to have all the files (jwrapper jar, jwrapper.xml and jwlicence.txt) in the same folder and run the compiler from that folder.
Guys I've written app in qt and when trying to run it (double click on *.exe) I'm getting error that this application cannot start because qtnetwork4.dll isn't available. I've searched my drive and I found few files with this name (and copied one by one every time trying to run my app) but none of them seems to work. How can I solve it?
place into your *.exe - folder appropriate dll-s from %QT_PATH%\bin\
There is an app called Dependency Walker that will let you know what functions in qtnetwork4.dll are being used in your program. It can be found at the following:
http://www.dependencywalker.com/
All of the DLLs your program use will be from the same installation as the qmake.exe that is used to compile the program. If you are using Qt Creator you can see where the qmake.exe your using is located by going to:
tools->options->Qt4
Get the DLLs that are located at the path displayed here to make sure they will work with your program.
On windows, DLL are looked for in folder where executable lies, then using "PATH" environenment variable.
In your case, you want to put your dll along your executable, taking them from the sdk you're using to compile
The following page provides a lot of additional information on the subject (example, plugins, strategy for building installers)
To force using QtNetwork and linking it, you have to put
QT += network
in your poject file.
If you're sure you're not using it, you can use
QT -= network
I want to created a JAR file and I want to run it on a client machine.So, I have a couple of questions:
How can I convert the JAR file to an EXE file?
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.
How can I create an installer? My clients doesn't have any JVM and I don't want to ship JDK or JRE along, because they have big size.
See this link: Java to Exe. It also explains what valid reasons are to do this, and when you should not.
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.
If you have an exe there are installers enough.
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/
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.
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.
May be Excelsior JET will satisfy your needs.) IMHO very mature product.
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.
Launch4j worked for me while some tools hadn't been working. It also have a good guide here.
Hope this help!
We use a 7zip SFX install launcher. This is an open source simple tool. It will package your jar, a version of jre so it's not mandatory for the installing systems to have jre installed and a self extracting version of 7zip. Here is a tutorial which explains how to bundle and GitHub link
The project is not maintained but works perfectly(tested until Java 1.8)
1) To create the exe, you can use Launch4j
2) As I have seen, you cannot encrypt the jar contents. I'm not sure though.
3) To create the installer you can use the exe you just created and use InnoSetup to create the files. You have to embed the jre inside the installer and also any other libraries and extra files that may need in the runtime. When embedding the jre, the setup gets large and if you want to avoid that, you can ask the clients to install java in the machines. That way, you wont need to ship with the jre.