Why JWrapper JRE does not include javaws - java

Why JWrapper JRE does not include javaws file, even when I using tag NoStripJREs=true.
How to run jnlp file using JWrapper JRE, like run another application via jnlp in runtime.

If the NoStripJRE tag is specified correctly you'll see this during the build output:
[Config] Will not strip JRE (leaving optional files)
However if you have already built the JRE then JWrapper won't build it again unless you delete the output JRE archives in your build folder. If you delete those then it will rebuild the JRE archives (this will take minutes) and it should leave the JRE as is.

Related

Is there a way I can bundle a jre in a Launch4j .exe file?

I would like to bundle a jre folder into my generated launch4j .exe file via maven pom.xml (For some reason, I don't want an installer, just a click to run Java application that has its own embedded jre). Is it possible? I have read through several posts and I don't get a maven automated one. I don't want to do it the manual way, just by packaging through maven because of some reasons
I've tried bundling a jre folder into an exe file via maven but it ends up not running after I uninstall java from my system or after I remove the jre folder from which the pom.xml Launch4j configuration was using . Kindly assist.
Update: I found a perfect tool for just the above task, Warp-Packer. The software just requires a few CMD commands/terminal commands to compress and add your JRE and pre-generated executable(from software like Launch4j or any of your preference) to one .EXE file which requires no installation. Click to run.
Basically, it is a simple command like:
cd %jre_folder% - %jre_folder% is the path to your folder where the warp-packer.exe, JRE and pre-generated exe(in my case myapp.exe) file are.
then type the following:
.\warp-`packer` --arch windows-x64 --input_dir jre_folder --exec myapp.exe --output myapp.exe
The image below illustrates that

How do I execute a method from a library jar on a different JRE than my current project's JRE

I have a project 1 which need to run on 1.7, this project has a dependency on another project 2 built on 1.8.
I am trying to invoke a class from Project 2 inside Project 1, but I am getting a known error which is fixed in 1.8. I f I run this class individually on Project 2 in JRE 1.8, it works fine.
Any leads to chose the target JRE dynamically for a method call?
If you are willing to make a jar and use a wrapper for each program, you can bundle a specific jre with each executable.
Download and run Launch4j
In your eclipse project, click on:
File -> export -> runnable jar file -> next
And select the run configuration for the project you'd like to extract. Hit Finish
It's a good idea to test each jar and make sure it runs. Double click, or find it with cmd and do java -jar nameOfJarToTest.jar.
Make a subfolder for your jre. I just called mine "jre".
Copy and paste your bin and lib folders from the correct jre into that folder you just made. Mine are located in a place like C:\Program Files\Java\jre1.8.0_201 if you wanted to run java 8. To be extra clear, your file structure should be
someContainerFolder(folder you just made)
nameOfJarToTest.jar
jre(folder you just made)
bin(folder copied from the jre in your file system)
lib(folder copied from the jre in your file system)
Run Launch4j. Add the .jar and select an output file path. Fields pictured below
Click on the jre tab and add your respective jre in the min jre field. Make sure you select the option Only use private jdk runtimes. Type "jre"(if you named the folder with 'bin' and 'lib' jre) in the "bundled jre path" field pictured below.
Click on 'build wrapper'. It looks like a settings cog.
If you do this for both jar files, and make sure the 'bin' and 'lib' folders are from the jre you want to run, the two programs will both run fine in different runtime environments. If you would like one program to be able to call the other, I found the geeksforgeeks website has a very simple and concise way for you to call external executable files from your code if you're okay with canonical paths.
This is not possible, if your project depends on 1.7 it's dependencies should also be 1.7. At runtime all code executes in the same JVM, there is no way to dynamically 'choose' a target JRE.
If you really have no other option and the two libraries should work together, you could possibly build some kind of bridge between project 1 and 2, where project 1 invokes project 2 in a separate JVM instance.

Where is the Java "jar" function

I'm looking to make a jar file out some Java code using jar [options] [name] [files] from the command line but it's not recognized.
According to Oracle Jar is part of the JDK. I have both 7 and 8 installed. How do I run the jar function?
I don't have a C:/Java that the Oracle documents show. I've tried running jar from within the JDK directories and with admin rights.
I'm not putting params in yet, want to check I can at least find the jar function first.
Running jar from JDK directory(1.8) http://puu.sh/eoer7/4fcd0ce63c.png
Running jar from System32 http://puu.sh/eoe3X/076d79b4e4.png
You have displayed two installations of the Java Runtime Environment (or JRE). You need to install a Java Developer Kit (or JDK), to get jar. Set your JAVA_HOME to the installation directory of the JDK, and add it to your PATH.
set "PATH=%PATH%;%JAVA_HOME%\bin"
Also, Using JAR Files: The Basics says (in part) JAR files are packaged with the ZIP file format, and you can use tools that can read and write ZIP files to work with them.

How to run built java file with the extension .jar

I made a desktop application with Java netbeans, it's a Jframe with some components. I built it and the .jar file created in the dist folder in the project folder. I have already the jre (Java Runtime Environment) installed on my pc. When I try to open the .jar with the jre I got nothing, Nothing appears. What can I do ?
https://netbeans.org/kb/articles/javase-deploy.html#Exercise_1
The link above will take you to a tutorial. Jar files are not executable by default. You need to specify a starting class to make a jar file executable.
If this doesn't work, then make sure you have called setVisible(true) on your JFrame.
Edited to add: (author added info)
When I try to run through CMD there's Unsupported major.minor version 52.0
This means your JRE version does not match your compiler version. You can confirm with the -version option, then fix your path to use Java from the same place your compiler lives.

Installing Oracle JDK 6u38 on Fedora 17 in user home directory

In the older version of Java 6, Oracle provides the tar.gz distribution for their JDK, which can be extracted and run in user home directory without installing to system folder. However, the latest versions of Java are no longer distributed as tar.gz format for downloading anymore. Does anyone know how to install the bin distribution in user folder without root privilege?
I have tried to extract the bin files but it's not usable since most of the jar files are encrypted (or packaged) in some weird format (.pack), e.g. rt.pack instead of rt.jar. I have also tried to use --prefix in the rpm command line but it requires root permission. They seems to make it impossible to install java in user home directory.
Here it says:
The Java Development Kit files are installed in a directory called
jdk.6.0_ in the current directory.
And it looks quite simple, it just says to give execution permissions and execute a bin file.

Categories

Resources