AppBundler doesn't include binaries from JRE in OS X Java App - java

I'm trying to to package my java app into an OS X App Bundle and I want to include the JRE, so it can run without a installed JRE.
I'm following http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
The AppBundler Ant Task will generate a .app with the JRE included but it is missing all the binaries.
The App will run but i'm not sure it's not using my installed JRE instead as it's missing the binaries. Or does the included JavaAppLauncher replaces the normal java binary?

The bin/ folder is not included when bundling the JRE in an app. The only native binaries it uses are in MyApp/Contents/MacOS and MyApp/Contents/Plugins/MyJRE/Contents/MacOS.
Or does the included JavaAppLauncher replaces the normal java binary?
The app bundle does not call a 'java' command. Some combination of JavaAppLauncher and libjli.dylib invokes Java dynamically.
If you are unsure if it is using the bundled version of Java, output this when your app runs. It will tell you from what location Java is being called:
System.getProperty("java.home", "")

Related

How can I run main jar without JDK on a Mac?

I've been using the discontinued BuildDesk to compile and bundle my Java desktop application but it forces user to use legacy Java in macOS. I would like users to use latest as some users feel queazy about the word legacy.
I found a script to create an .app bundle. When I export the main jar from Netbeans (Run Target > Other Targets > package-for-store) and include the jar, libs and resources in the bundle, it runs OK but requires JDK to be installed, unlike the compiled app from BuildDesk.
Is there a way to bundle the jar so user doesn't need to download a JDK? I have found answers for Windows, not macOS. Some say no need for JDK, just JRE but I cannot get app to run if I have only JRE on my Mac.
Thanks.
this is apparenlty because of a bug in mac and java : https://bugs.openjdk.java.net/browse/JDK-7131356
which leads java 1.6 (made by apple not oracle) to be required under any circustance of running a java app.
(even if the app is self-contained apparently)

Create standalone executable from Java code for Windows, OSX and Linux all at once

i'm coding a project in Java and building it with gradle.
I need to keep it simple and compile it into standalone binaries for Windows, Mac and Linux.
Is there anything which can build all of this binaries or must i use a separate lib (like Launch4j for Windows executables) for every single binary?
I'd like to call a single "build-all-binarys"-like task in gradle and get a .exe, .app and .bin file out of it.
It would be nice to have the possibility to bundle a JRE into the binary as well.
Use the javapackager, added since Java 8 in the JDK.
It nicely creates a self contained executable - that's it bundles the JVM with every copy - of all standard operating systems with one call.
The javapackager is located in JAVA_HOME/bin/ directory.

E(fx)clipce with Inno Setup wrong jre folder name

I am following JavaFX tutorial found at
http://code.makery.ch/java/javafx-8-tutorial-part7/
which describes how to create native installer with 'Inno Setup'.
I am using e(fx)clipse 4.4 with java 8 JRE installed only and 1.8 compiler
and i do it for windows (exe).
Everything works fine, but when i install exported native application it create folders for JRE
runtime/jre8/
program wont start and says
jvm.dll is not found in bundled runtime.
if i change manualy runtime/jre8/ to runtime/jre/ - it start without any problem.
I did not found any settings in project for specifing runtime path.
How do i make my native installer make right path for runtime?
Solved. Just noticed that i was using standalone jre for project c:\dev\java\jre8 but supposed to use jre from jdk package c:\dev\java\jdk1.8.0_05\jre.
Now installer creates proper path for runtime - runtime/jre/

Java Browser Plugin Or Manually installing Java

Here is my question i installed Java Plugin for Chrome it does mean i have installed java in my machine...And after installing this plugin can i run below command
java -jar myfile.jar
through a batch file or i have to install java in my machine and setup class-path then it should work?
If i will install Java browser plugin it automatically installed java in my machine and setup path as well.
Its hard for me t understand the situation how it works. Can anyone help me on this?
The JRE is the Java Runtime Environment, i.e. the software you need to interpret and execute Java class files. The Java browser plugin is the bridge between the JRE and the browser, used to run Java classes of applets embedded in HTML.
You can check the Java plugin of Chrome browser in this link.
The plugin is bundled with the JRE, and runs inside a browser, allowing Java code to run inside the browser process on the client. The main entry point class must be written as an Applet when the plugin is used, but all the Java code it calls can be just regular Java.
There are limitations when running Java code with the Java plugin for security reasons. All code shall run within sandbox with limited access to the file system and such.
Also as the plugin check for installed JRE version at your machine, that means you do have JRE.
You can install as many JDKs as you like. Just put them in different folders.
The one you refer to on the path is your choice - but presumably you'd choose the one that you want to use whenever you type "java ...." commands at the command line. In the absence of any other factors you should probably set this to be your most recent JDK version.
Note that your IDE may support multiple JDKs, for example Eclipse has "Preferences / Java / Installed JREs" where you can set up multiple JDKs/JREs for use with Eclipse
Please first check your machine contains java (jdk or jre)
java -version -- if you get a valid output then you have java in your machine.
in order to run java -jar myfile.jar , you should install java (jre or jdk) in your machine and class path set to the relevant location. To run this you should install jdk or jre in your machine. Most program only need the JRE (Java Runtime Environment) but some programs need the Compiler at runtime in which case you need the JDK.
Please refer this link to find out How to set class path .
Then you will be able to run your command.

JAR file does not load class files from ext

I installed JDK 1.6 on my Linux system, the $JAVA _HOME directory is /usr/java/jdk1.6.0_07.
I built the path on Eclipse to $JAVA_HOME. It runs smoothly through Eclipse and loads all third party JAR files from /usr/java/jdk1.6.0_07/jre/lib/ext/, but when I export the JAR file and run it, it throws ClassNotFoundExecption.
Why?
Did you install Java properly? Here are some instruction for installing Java 7 or Java 6
Are you sure that the version of Java you are using is correct one since there can be several versions of java on linux? Try java -version on terminal where you run it to check.
Do you use any third party library? If so, did you specify the class path when you run the jar file or bundle them inside your jar file?
What does java -version return? Are you using the same JRE for execution?

Categories