I have created a Java application. And its ready for deployment.
I have made jar file from my code. wrapped it using launch4j and bundled jre with it and accessing my exe file(generated by launch4j).
So,No need to install JRE and Everything works fine.
But one small problem is that my Exe file has to be at some predefined relative path to the Bundled JRE.
For example let say user has installed it in E:/(My Soft) where My soft contains JRE files an my Exe file. Now if user copies the exe file to his desktop then he will not be able to execute it.
So, I want to is there any way i can bundle jre within my exe or any other tweek so that user can Execute the exe file from anywhere on his pc ?
Try use jnlp starter for your programms. Read more in official oracle documentation JNLP
There's one option to bundle JRE with exe is to create a Portable Edition app with for example jPortable. So you can execute exe anywhere on the PC without installing JRE. But the better option is to create a custom installer which will check current installation of JRE in the client PC and install it as an required option if no other compatible JRE found.
Related
After installing Oracle Db, Sql developer is asking "Enter the full pathname for java.exe" .
I have installed java deveopment kit, so I browse for java exe file in jdk1.8.0_151 /bin. After clicking ok, the same widnow with the same msg is still there ("Enter the full pathname for java.exe"), does anybody know how to fix that?
I have tried to reinstall , but nothing changed.
TY
Did you consider downloading Windows 64-bit with JDK 8 included so that you wouldn't need to worry about JDK? Installation notes say:
This archive includes both SQL Developer and an embedded copy of the Java 8 Development Kit (JDK). Simply extract the zip to a fresh directory and run the sqldeveloper.exe in the top directory. The EXE is configured to run the embedded JDK by default.
More info here.
Is there a way to prevent that the Java installation routine (e.g. jdk-7u1-windows-i586.exe) copies java.exe into C:\Windows\system32 directory?
I have to install my software on a client's laptop and I don't want to break other Java applications which are already installed on the machine. In other words I want to install a private JRE which is only used by my software.
By now, I copied an already installed JRE from my computer to the client's machine.
I discovered yesterday that there is a problem with Java versions on Windows, as you know keeping java up to date these days is critical, especially the JRE used by Internet explorer located in the Windows system32 or syswow64 folder.
You can perform a search for java in your C: drive and look at the various executable files it finds to determine if the situation applies on a specific system.
After doing some research I find that when the Java updater runs, it only updates the files installed in the JAVA home , usually located on the program files, but it does NOT update the files located in the windows system folder. As a result and since the system folder is in the default system PATH , the usage of Internet Explorer continues to use an old version of the JAVA files ( java.exe , javaw.exe , javaws.exe )
The solution is to uninstall java using the control panel uninstall programs feature, download most recent version and install again.
Cheers!
Fernando
I recently upgraded to java 8 and discovered this problem as the java version under system32 was still java 7. It stops you even running version as it complains about the registry keys
U:\>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
Doing the following pointed me to the culprit:
U:\>where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.8.0_45\bin\java.exe
I 'solved' this problem by just deleting the java under system32! I'm unsure of what consequences this will have.
You can just provide the JRE you want to use on your software and:
Set the JAVA_HOME variable before you run your application
Point to the correct java.exe file (e.g. ..\jre1.5.0_22\bin\java <your_java_main>)
This can be done in a *.bat file for example.
After running the *.bat file you created, all other java version will be ignored and it won't matter which versions are, or will be, installed on that pc.
I found the newest JDK still doesn't write correct code against registry.
The issue is if a computer doesn't have JRE, JDK doesn't register JRE in registry correctly.
For those install JDK 1.7u72 Just add Software\JavaSoft\Java Runtime Environment as the error message indicate. And add a string entry of CurrentVersion with value 1.7.
And then add Software\JavaSoft\Java Runtime Environment\1.7 and put a JavaHome string entry with value "C:\Program Files\Java\jre7". And JRE will function correctly.
Blame Oracle, if you use Registry, then write correct code, otherwise don't use the Registry!
All you have to do is go to Control Panel -> Programs Uninstall a program. Uninstall the old java updates and keep the newest java update and java development kit update. Your newest java update and java development kit update should have the same number.
Windows 10 Solution
Check Java Version in Console (CMD) with java -version
Check in Console (CMD) with where java, which Java Path's are enlisted.
If it you shows you "C:\Windows\System32" in its output, you will have a problem to get to your %JAVA_HOME%, where your wanted Java version resides.
Meaning, you need to get rid of "java.exe" in "C:\Windows\System32".
Just uninstall the JRE in the Software ("Programs and Features")
Hint: Keep in mind, do NOT the JDK, here in my case "Java SE Development Kit 8 Update (64-bit)"), but the JRE.
One way I would try would be to create a write-only empty file with the name java.exe into the System32 folder.
I have Launch4J on my computer and it's a great program. One of its features I'm interested in is the ability to bundle a JRE in the general .EXE file. However, I can't find any documentation that describes how to go about doing this.
How do I bundle a JRE with the EXE? Plus, where do I get a compact, portable JRE to run? The download links on Oracle are for the installer packages.
After some attempts i finally get a workaround to bundle the jre in my application:
I package my app as a zip file with the following folders inside:
containerFolder
|- jre
|-bin (in bin there is java.exe)
|-lib
|- cfg (to save the user configuration, but it's not needed)
|- bin (my application with the .exe and the .jar and all the other stuff)
In the xml file of launch4j i configure the jre like this:
<jre>
<path>../jre</path>
<opt>-DgvSIG.confDir=../cfg</opt>
</jre>
The trick here is that the path is not to the java.exe file. The path to the jre is relative to the position of the .exe and it should point to one folder before the java.exe file
The jre folder i'm using is just a copy&paste from the jre folder installed on a windows system.
I did the following and it worked for me using ver Launch4j 3.11:
Created a new folder for my application (called for example
MyApp).
Copied the jar file from the java project dist folder to the MyApp
along with the lib folder.
Created a folder called jre in my application folder MyApp
so now MyApp folder contains:
MyApp.jar
lib <- this has the libraries needed by my java app.
jre
Copied the bin and lib folders from java jre folder (C:\Program
Files (x86)\Java\jre7) to MyApp\jre
In the Launch4j having set all the required options, then set the
Bundled JRE path to "jre"
Make sure that in the search options "Only use private JDK runtimes"
is selected.
The same problem like you mate. No worries now. Its all solve with the maximum depth to solve future solution.
Solution how you can bundle your JRE for your jar without the need that the user has to install java or not. Your java application will run.
Copy lib and bin folder from your JRE folder to your project dist folder
open launch4j and enter the following setting.
The trick is you need to give the full path to the including javaw.exe.
Enjoy!!!!
I have just done this. Above clearly describe the method for bundling jre.
Here, I just share an experience that I have struggled. If you want to create an installer exe after created wrapper exe by launch4j, pay attention to the file path for launch4j and jre. This is my path I used to solve my issues:
launch4j, bin/jre, resources/bin/jre.
launch4j, bin, and resources are at same level.
The jre can usually be found in your SDK folder. Yes the links online are installers, but once it installs, the JRE is now located on your local disk. Mine is located in
${jdk folder}\jre
The parts that you don't need from the JRE could probably be removed manually if you really wanted (I'm not sure whats available online).
A working example of using Launch4J to bundle a Java application with a specific JRE can be found at https://github.com/vZome/vzome/blob/master/desktop/platform/windows/README.md. This particular distribution is configured to require vZome to use the bundled JRE rather than any JRE found on the target platform.
Hope this helps.
Where can I get the latest jdk as a zip file. I don't want the jre, I want the full jdk. I can't run exe's or even request windows installer so it's impossible for me to download the .exe and run it. Also I can't access some uploading sites like Drop box or 4shared. Is there any ftp or place that I can get just zipped up jdk? Thanks you very much. Jportable is not good enough, Thanks.
http://installbuilder.bitrock.com/java/ all the version are available. enjoy. all are ZIP
Ideally, Oracle would provide us with the option of downloading the JDK binaries as a ZIP package instead of forcing us to use the Windows installer. But since they don't, why don't you try downloading the ZIP distribution of another Oracle product that already includes a JDK (e.g. Oracle SQLDeveloper). And please be sure to come back here and let us know if this approach worked out for you. I'm sure there are tons of folks out there looking for workaround too.
It's really simple but, you have to make it yourself.
First, download the JDK from the Oracle Website.
Second, extract all the contents using 7zip or other extracting utility.
Third, navigate through the extracted content and use Java's "unpack200" to convert all the ".pack" files (there's a couple of them) into jar files. You can delete the ".pack" files afterwards if desired.
Note: In order to use unpack200 you need to have a JDK installed on the system. Navigate to the jdk1.x.x_xx/bin folder an run the utility from the command line.
Example: unpack200 rt.pack rt.jar
Thanks.
You can install jdk (with installer, uncheck 'public jre' option), zip installation folder.
Then uninstall jdk. Now you have a jdk zip, you can unzip wherever.
I'm using jdk this way on Windows Vista, both jdk 1.6, and 1.7.
I was also facing the same issue - to get a zip version of JDK7 on my PC. Tried to extract the exe installer and was happy to find that I got a set of folders including jdk,jre, lib,bin etc (similar to the set up that you get by running the installer for Jdk8). But my happiness was short lived - Eclipse did not recognize this path as a valid JDK / JRE installation , while I set up the additional Run time environments.
The fix is to run the exe installer and install it in a different path , outside Program files, so that it doesnt mess up your Java home settings or JRE versions for other client programs.
i have to install JRE Programmability if the System does not have JRE, i had dected JRE is installed in the system or not, but i have no idea how to install JRE programmtically, some people said you can use installer, but i donot know how to use installer for this purpose i searched in sun documnet, installing JRE in slient mode, there's also i donot know how to use that command iie.fing.edu.uy/ense/asign/…
In order to run your Java program, you can do that without installing the JRE, that its, you can run the application in a computer without JRE, we do that every day.
The way is to deploy you application with an embedded JRE and use a script (.bar, .sh) to execute you application using the embedded JRE. So your application is self-contained and no requires external JRE. You need to copy the entire JRE folder into your application and start removing unused files using the test-error approach. You can also decrease the file sizes removing not needed classes, like in rt.jar (you can decompress, remove unused classes and zip again).
The problem with this approach is that you are violating the Oracle/SUN JRE distribution policy as you are distributing a JRE with fewer files. If the application is for internal use, I think it's OK, if you want to redistribute the application, you are in trouble.
Another question is how to install the JRE by code, you can try to ship the JRE with your application, using an installer detect if JRE is already installed and install it id needed. Doing that in Java code is not trivial, you can use Runtime to exec external programs...
Do not rely on JAVA_HOMEas is not actively used nowadays.
Example:
Say you application name is 'A', you folder structure can look like:
A
|-> Run.bat
|- jre
|- bin
|- lib
|- lib
|-> A.jar
You application main class is Main.java in package a. Your Run.batcan look like START "" jre\bin\javaw.exe -cp lib\A.jar a.Main
You only are calling the embedded jre in jre folder, by calling the bin\javaw.exe and passing the jar and main class. The jre folder can content and entire JRE as copied from c:\Program Files (x86)\Java\jre6\ (Windows 7).
If you can have a web based solution you can use deployjava
http://download.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html