How to run jar with JOGL app without -D key? - java

I tried top learn Java because it's the easiest way to make cross platform apps(python too but I've already know it). I tried to write hello world program with JOGL. I've written it and it runs perfectly in my Eclipse and NetBeans but when I'm trying to build jar and run it it says that there isn't JOGl in the java.library.path. I tried to pass library path with -D argument and it works!
The question: Is there is a way to run it without any additional args? With only double click.
Thanks.

You should create a manifest file in your project: META-INF/MANIFEST.MF (probably you already have it in your project tree).
And There you can specify your classpath, for example:
Class-Path: lib/jogl.jar lib/other_lib.jar
Then make sure that this file goes in your jar. For more information http://download.oracle.com/javase/tutorial/deployment/jar/manifestindex.html

When it comes time to deploy to users, deploy the app. using Java Web Start. That makes using natives a 'one click' install for the end-user, and it can also partition the native download between platforms.
Is there is a way to run it without any additional args? With only double click.
JWS also offers desktop integration - desktop shortcuts and menu items with icons, on the supported OS'.

You can do the above very easily using a tool like JarSplice. Just follow the gui, its pretty easy to do. The application will put the natives inside the jar for you, so all you have to do is double click the jar to run your jogl application.

Setting the Java library path is no more required in JOGL 2.0. You just need to set the class path (jogl-all.jar and gluegen-rt.jar must be in the class path) and to put the JARs containing the native libraries into the same directories whatever you use (applications, applets, Java Web Start, etc...). Then, JOGL 2.0 automatically loads the native libraries.

Related

Deploying a JavaFX program using Java 11

I am trying to deploy my JavaFX project (which uses Java 11). I found some other tips online that said to create a Launcher class which does not extend Application and call the actual main method from the Launcher class.
Although this allowed me to create a JAR that I could run in the desktop, it required me to provide a path to my JavaFX library folders in the command line.
Since I am deploying this project, I do not want to force users to have to download the entire JavaFX library.
Is there a way to deploy my JavaFX project without requiring users to have the entire JavaFX library folders downloaded? I am especially confused because it seems that the JAR already has the JavaFX library folders in it, as the JAR file size is large.
I would also like to avoid using any third-party libraries or tools.
For reference, I am using IntelliJ IDEA.

Creating an installer for Java desktop application

I know this question has been asked many a times and all the time there is an answer which says about using an executable jar or making an .exe using launch4j or similar app.
I may sound like a novice, which I actually am.
I have been trying a few things with a Java project. I have successfully made an executable jar and also an .exe file from it. All thanks to your previous answers in SO :)
But, I want to create a installer for Windows. Like, pressing Next for 2 - 3 times(which shows all the terms and conditions etc), then a user specify a location(like C:\Program Files\New Folder\My App), then my .exe, lib folder, img folder, other important folders get pasted in the destination folder along with the .exe file and then a shortcut is created on a desktop.
Any pointers to how can I achieve this ?
I have been using InnoSetup for a long time. It has always worked very well. It can do everything you need (unpack files, put shortcuts on desktop, start menu etc) and generates installers that we are used to.
If you want free and open source, you could take a look IzPack. We use this at work for its command line support in our builder.
You could also take a look install4j which is a commercial product we've trialed on and off before (but when it comes to spending money, you tend to want to know you're getting what you want ;))
If you are on JDK 13 or above, you can package any Java program along with its runtime by using the default packaging tool in the JDK called jpackage.
jpackage can create installers for Linux, Mac and Windows operating system.
You can create a specific runtime by using jlink.
jpackage needs some 3rd party free software for creating Windows bundles:
* To create .exe bundle, it uses Wix
* To create .msi bundle, it uses Inno
Wix is now the only dependency to create both exe and msi bundles.
All the details about jpackage can be found at JEP 343: Packaging Tool.
Edit: I'll leave this here for reference, but note: The Java plug-in needed to launch JWS and applets was removed by browser manufacturers, and both were deprecated in Java 9 and removed from the API.
Use Java Web Start.
Like, pressing Next for 2 - 3 times (which shows all the terms and conditions etc)
The ExtensionInstallerService of the JNLP API provides this. Here is a demo. of the installer service.
..then a user specify a location(like C:\Program Files\New Folder\My App), ..
The ExtensionInstallerService provides a method getInstallPath() which..
Returns the directory where the installer is recommended to install the extension in. It is not required that the installer install in this directory, this is merely a suggested path.
That is not quite the same as what you are asking, but then I think it is generally a bad idea to allow the user that level of control.
then my .exe, lib folder, img folder, other important folders get pasted in the destination folder along with the .exe file ..
JWS installs the resources mentioned in the JNLP automatically, as and when they are needed. Further, it updates the resources if the archives on the server change.
and then a shortcut is created on a desktop.
JWS can supply desktop shortcuts and menu items on supported systems.
E.G.
From How to run Java programs by clicking on their icon on Windows?
This answer, which shows a JWS app. installed in 'Programs and Features', with the desktop icon to the left of it.
I was in the same situation a few months ago. After trying out a lot. I suggest NSIS. There is a nice plug-in for Eclipse EclipseNSIS with some templates. It helps a lot to get a basic installer with just some easy clicks. If the resulting code is not sufficient you can do the rest work by coding, but most of the code is generated by EclipseNSIS.
You can also use Advanced Installer. Since you already have an EXE to launch your JAR, you don't need to use the Java Launcher support from Advanced Installer, you can create a Simple project, which is available in the free edition, so you don't need to purchase a license.
It will take you maximum 10 minutes to install it and create the setup package, as you will see it is very easy to learn using it.
use Launch4j to create exe file. you must give the relative path to jre folder.
next use Inno Setup to make setup. You can bundle jre inside the installer.
I've use it and it works like a magic. I can show details.
I wanted to share another project. This project have two part:updating your desktop app and ready installers for mac os, linux, windows. If you want only installer so you can adopt for your needs documentation in this way you should replace starter-core-1.0.jar with your jar

Java application deploy

I have a Swing desktop application and have created a jar file which depends on library (which is kept in ./lib/) and a .txt file in the same folder. Now to execute the jar I have written a .bat file which checks if Java is installed or not. If installed then I run the jar file with command:
javaw -jar TagEdit.jar
Now there are two problems I am facing with this:
I would rather prefer a single executable, if possible.
As using bat file, the console is visible in back (looks kind of weird). Is it possible to turn it off?
Java is everywhere, and there are lots of applications that are built in Java and packaged in a setup, or given as exe. I Googled a lot but could not find a way to create a setup for the software or an exe. How are those software packaged?
Have tried jlaunch, but could not get that to work correctly.
Himz, Eclipse can automatically build a so-called "fat-jar" for you. It is a jar that contains all the dependencies you need.
If you are a happy Maven user, then you have two brilliant alternatives - the shade plugin, and the assembly plugin. They both can produce a "fat-jar" for you. :)
There are various answers to this.
javaws.exe will execute the jar without the console appearing behind
But I feel this isn't really the best way.
I think should investigate using Java Web Start, So you create a JNLP file and have it jar downloaded from the web, I think, you can also have a desktop icon.
If you don't want that
I think you can get/buy binary wrappers for the jar.
You could convert it to an executable. Try Googling java to exe.
Once that is done, you could package it up as an installer using NSIS.

How to use 3rd party packages in Java

I'm developping my first Java application which actually needs a 3rd party package and now I'm lost as to how to actually use it. The packages I need are from VLCJ so that I can embed a media player in my GUI.
Usually, I can just import packages and classes, but is this possible with 3rd party packages? They have a .jar file to download at their website, are the packages stored in that? And if so, how do I go about using them in my own application?
You just need the third party JAR to be on your project's classpath. What IDE are you using? In Eclipse you would do:
Go to Package Explorer window on the
left. Select the Java project you are
working on and right click. Click
Properties. Then click Java Build
Path. Click Add External Jars.
Or you could modify your system wide CLASSPATH to include the JAR. Or you can do it on the command line e.g.
java -classpath C:\java\thirdpartjars\thirdparty.jar MyProgram
(you can use the argument with javac too).
There are many ways to crack this nut.
Yes, the JAR file you download is an archive (basically a .zip file) of compiled .class files which you can then import into your own application.
The only thing is you need to add the .jar file to your application's classpath for you to use it before you can import it.
I would suggest looking at a good Java book or tutorial (for example, the official Java tutorial) as this is all stuff that should be covered.
You need to add the jar file to the search path of javac when you compile your project; and you need to make the jar available at runtime-- it needs to be in the classpath of the java process that runs your program.
If you are using an IDE, you usually update these paths in the project settings.

How to convert jar files into exe & rpm

I have the following jar files for my app:
DesktopApplication1.jar
Plus , i have used the some extra API's for my app , like jsoup, jexcelapi etc. There are about 7 api's in the lib folder.
How to make a EXE file & RPM file out of all these jar files?
P.S. I am a first timer. So take that into consideration.also, I have used Netbeans 6.8. So the main API is in \dist folder. And the API used is in \dist\lib folder.
thanks in Advance
use jsmooth to make exe from jar
Build your JAR with fatJar to include all the dependencies in it, and then make it executable with your favorite tool (I use Launch4j)
RPM is little bit different, since it is not executable, but package format. There are lots of tutorials, how you build it up.
You could make a BAT file a file with .bat(For windows) extension
Just open notepad and write the following text
java -jar DesktopApplication1.jar
Save the file as filename.bat(the .bat extension is important)
Place the .jar and .bat files together and just double click the .bat file every time you need to run the jar...
If you don't want to keep both together then give the absolute path of the jar in the .bat file
java -jar AbsolutePath/DesktopApplication1.jar
For a linux machine make a file with (.sh) extension rest of the procedure is same...
Try InstallJammer. It provides what you want.
Deploy the app. with Java Web Start. JWS Can make it easy to add other Jars to the apps. run-time class-path, avoiding the common problem with fat jar of violating the API's distribution license (when it says WTE 'you are allowed to distribute this in unaltered form..') and can provide the further benefit of only downloading the parts that the user requires (when the user requires them).
JWS has many other cool features like desktop integration (menu bars, start menu item), splash screens, automatic updates, support by the owners of Java, and compatibility with any platform for which Java is available.
For creating .exe to run on Windows:
Download launch4j from http://launch4j.sourceforge.net.
build wrapper .exe through launch4j.
Download innoSetup from http://www.jrsoftware.org/isdl.php.
Build .exe as installer, the setup file, for user to download and install.
Install rpm for linux:
If your application used other native libraries, you need to download and install Linux native libraries. This is how we build rpm for our app.

Categories

Resources