What are the differences between private jre and public jre?
Is there some official paper about this topic?
I didn't find any question on SO about this topic. Nor I was able to find something fulfilling around.
A JRE is nothing but a folder that contains JVM executables, setting
files, required lib files, and extensions. You can install multiple
JREs on your system Sun generally installs versions in C:\Program
Files\Java as jre eg.jre1.6.0_06.
A Public JRE is available to all Java programs, Browsers, and the libs
in this JRE folder are available to applications started in command
line like java com.sarathonline.cli.HelloWorld This JRE is also
registered in path, and Browser plugin.
A Private JRE is something that is installed in the system but is not
referred to by default. This could be a copy of the JRE / JDK folder
from another installed directory. If you see a my earlier post:
starting eclipse with jre 1.6 where your environment is in 1.4, The
JRE1.6 is used only by Eclipse, this is a private JRE. While the
JAVA_HOME points to 1.4. This is a public JRE.
Source:
http://blog.sarathonline.com/2008/07/public-and-private-jre.html
Some more discussion on the topic:
http://www.velocityreviews.com/forums/t649860-private-vs-public-jre-in-different-oss.html
The official answer, from Oracle:
Private Versus Public JRE
Installing the JDK also installs a private JRE and optionally a public
copy. The private JRE is required to run the tools included with the
JDK. It has no registry settings and is contained entirely in a jre
directory (typically at C:\Program Files\jdk1.8.0\jre) whose location
is known only to the JDK. On the other hand, the public JRE can be
used by other Java applications, is contained outside the JDK
(typically at C:\Program Files\Java\jre1.8.0), is registered with the
Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be
removed using Add/Remove Programs, might be registered with browsers,
and might have the java.exe file copied to the Windows system
directory (which would make it the default system Java platform).
The answer is very simple: the public JRE is the one users will use if they want to run anything Java. The private JRE is a different installation that one can use, if the explicitly execute that Java binary (e.g. on Windows: "C:\Programs\Java\MyJava\bin\java.exe").
Private JRE ->Private JRE is Used for compilation of Java Application when both Public and private JRE is available and its installation location is defined by user.
Public JRE -> Public JRE is used for Execution of Java Application when both Public and private JRE is available....if in case Private JRE is not available then both Compilation and Execution process will be done by Public JRE.
Related
The Anylogic installation package (v. 8.2.3) includes JRE (Java version 9.0.1).
I need to run Anylogic with a different JRE (Java 8)
Is this possible?
Yes, it is possible. AnyLogic uses built-in JRE, located in AnyLogic installation folder. At Windows it looks like this: C:\Program Files\AnyLogic 8 Professional\jre
You can install Oracle JRE and copy its jre1.8.0_... folder in AnyLogic installation folder. Rename the existing jre to jre_9, jre1.8... to jre. Launch AnyLogic, it will use the respective JRE.
I am shipping a executable jar file to customer, Customer has installed JRE 5, JRE 6 and JRE 7 on the box. My Jar required JRE 7 to run.
Without changing the system PATH (Environment var) how can I specify the JRE 7 to use?
You can specify full path to that JRE that you need, for example:
/path/to/jre/bin/java.exe -jar executable.jar
or
/path/to/jre/bin/javaw.exe -jar executable.jar
If you run this from a shell (script) then it is good practice to first set the JAVA_HOME environment variable to the right location before (/path/to/jre) before running the executable. You could first set/export JAVA_HOME and then extend it to the location of the Java executable (e.g. %JAVA_HOME%\bin\java.exe on Windows). More information here.
I'm not sure there's a cross-platform way to achieve this.
On Windows you can use a tool such as launch4j to wrap up the jar as a .exe that can select an appropriate JRE.
On Mac OS X you can have several different JDKs installed in parallel but only one public JRE (which will be at least the latest version out of the installed JDKs, and may be newer if it's been auto updated). It's the public JRE that is used for app bundles and when double clicking a JAR in finder.
The simplest way to do this, is to use Java WebStart to launch your program and then specify you need a suitably new version of Java. The launcher will then locate a suitable distribution on your system to use.
Using javaws also allows you to easily distribute new updates to your users.
Caveat: Caching has notoriously been a problem over the years. Ensure that when a jar changes content, its URL changes too.
I installed jdk 1.8. While installing, two JRE were copied to my computer:
The first is inside JDK folder and the second is outside .What's the purpose of having two JRE in the same Operating System .
Isn't one JRE enough to handle all requests .
Private vs. public JRE - Installing the JDK installs a private Java SE
Runtime Environment (JRE) and optionally a public copy. The private
JRE is required to run the tools included with the JDK. It has no
registry settings and is contained entirely in a jre directory
(typically at C:\Program Files\jdk1.6.0\jre) whose location is known
only to the JDK. On the other hand, the public JRE can be used by
other Java applications, is contained outside the JDK (typically at
C:\Program Files\Java\jre1.6.0), is registered with the Windows
registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed
using Add/Remove Programs, might or might not be registered with
browsers, and might or might not have java.exe copied to the Windows
system directory (making it the default system Java platform or not).
Source: http://www.oracle.com/technetwork/java/javase/install-windows-189425.html
Browser will run from java/jre
Java running from java/jdk/jre
When we install internet Explorer it will download jre
JDK/jre wil be use by the command line tool because command line default java home will be set to jdk with it looks for jre and run the java.exe inside the jdk/jre
Before downvoting or close-requesting this question please see that this question is about JDK 7 not 6, it has a second question 'Q2' which is not addressed by any duplicate thread and this question is about four not only two java.exe instances. Thank you!
I've just installed Oracle's Java SE JDK (64 bit) which resulted in the following directory layout, and somehow two JREs:
C:\Program Files\Java\
\jdk1.7.0_40
\jre
\jre7
I'm now the proud owner of four java.exe executables:
C:\Program Files\Java\jdk1.7.0_40\bin\java.exe
C:\Program Files\Java\jdk1.7.0_40\jre\bin\java.exe
C:\Program Files\Java\jre7\bin\java.exe
C:\Windows\System32\java.exe
Q1: Which one should I put into my search path to execute Java-based applications?
Q2: Do I need to put the Unlimited JCE Policy files just into the security sub-directory of the corresponding JRE in my search path or also into all others in order to work correctly?
While installing JDK you will have a copy of JRE installed automatically. You need not install a copy of JRE separately. yet this will be your directory structure.
The copy of JRE in the JDK folder is for the is a private copy of JRE.
Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK. On the other hand, the public JRE can be used by other Java applications, is contained outside the JDK (typically at C:\Program Files\Java\jre1.6.0), is registered with the Windows registry (at HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft), can be removed using Add/Remove Programs, might or might not be registered with browsers, and might or might not have java.exe copied to the Windows system directory (making it the default system Java platform or not)."
Which one should I put into my search path to execute Java-based
applications?
According to the "JDK and JRE File Structure" document, you should add jdk1.7.0\bin to the path:
c:\jdk1.7.0\bin
Executable files for the development tools contained in the Java Development Kit. The PATH environment variable should contain an entry
for this directory. For more information on the tools, see the JDK
Tools.
Do I need to put the Unlimited JCE Policy files just into the security
sub-directory of the corresponding JRE in my search path or also into
all others in order to work correctly?
According to the "Unlimited Strength Java(TM) Cryptography Extension Policy Files" documentation you will need to install the unlimited strength policy JAR files for all JREs that you plan to use.:
On Windows, for each JDK installation, there may be additional
JREs installed under the "Program Files" directory. Please make
sure that you install the unlimited strength policy JAR files
for all JREs that you plan to use.
So i decided to try the beta of android studio today, but it refuses to run on my 32-bit JRE. I can download the 64-bit JRE, but im not interested in it being my default JRE for various reasons (my current 32-bit eclipse IDE, Processing IDE and Minecraft doesn't like 64-bit to my experiences), and i think that swithing java_home dir all the time will be cumbersome.
So does intelliJ have some way of setting an alternative JAVA_HOME dir like eclipse does in its ini?
In IntelliJ you can specify which SDK to use at project level. go to "File" --> "Project Structure" --> SDKs (list on the left) and you can add/remove paths to different SDKs
Other solution: If you use Windows then I think you can specify JAVA_HOME as system property just for IntelliJ. If you use Linux the solution is similar.
I use IDEA_JDK for this purpose (on linux).
I believe it is STUDIO_JDK for android studio.
For more information on this and other jetbrains IDE's, see https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under
The other answers will not work for 64bit versions. Jetbrains have actually documented this quite well. From https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under:
Java 8
Please be aware that Java 8 is required to run IntelliJ IDEA starting from version 16 on all the supported platforms. It also applies to the lightweight IDEs released from the same branch (144+).
Windows
JDK is bundled with all the product installers and it's recommended that you will use the provided JDK version unless there are any specific issues.
32-bit JDK is located in IDE_HOME\jre directory and is used by the 32-bit product executable.
To run the IDE in 64-bit mode you will need to download and install 64-bit JDK (not JRE) distribution and install it yourself. IDE will find and use it from the registry when you run the 64-bit .exe file (available only for IntelliJ IDEA right now, other products can use the .bat file to run in 64-bit mode).
<product>.exe uses this JDK search sequence:
IDEA_JDK / PHPSTORM_JDK / WEBIDE_JDK / PYCHARM_JDK / RUBYMINE_JDK / CLION_JDK / DATAGRIP_JDK environment variable (depends on the
product, WEBIDE_JDK applies to both WebStorm and PhpStorm before
version 2016.1)
..\jre directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
idea64.exe uses this JDK search sequence:
IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
It’s also possible to start the IDE with .bat file located in the bin directory, it uses the following JDK search sequence:
IDEA_JDK / PHPSTORM_JDK / WEBIDE_JDK / PYCHARM_JDK / RUBYMINE_JDK / CLION_JDK / DATAGRIP_JDK environment variable (depends on the product)
..\jre directory
JDK_HOME environment variable
JAVA_HOME environment variable
Environment variable must point to the JDK installation home directory, for example:
c:\Program Files (x86)\Java\jdk1.8.0_66
The actual JDK version used by the IDE can be verified in Help | About dialog (open any project to access the menu).
Define IDEA_JDK / PHPSTORM_JDK / WEBIDE_JDK / PYCHARM_JDK / RUBYMINE_JDK / CLION_JDK / DATAGRIP_JDK variable depending on the product to override the default version from IDE_HOME\jre.
Use Rapid Environment Editor to add/edit the variables, it will detect incorrect paths.
Linux
Starting from IntelliJ IDEA 16 and the most recent versions of the lightweight IDEs, we are bundling custom JRE with Linux distributions, just like we've been doing for Mac. Our custom JRE is based on OpenJDK and includes the most up to date fixes to provide better user experience on Linux (like font rendering improvements and HiDPI support).
Boot JDK path is stored in the .jdk file located in the config folder. It can be modified either via the Change IDE boot JDK action or by manually editing .jdk file (if you can't start the IDE to change it via an action).
It's recommended to use the bundled JRE (if available). In case you have any issues with the bundled version, you can switch to the latest version of Oracle JDK or OpenJDK available for your system (OpenJDK 1.6 is not supported, please use 1.7 or later versions, JDK 1.8 is recommended and older Java versions are not supported starting from IntelliJ IDEA 16).
Check bin/.sh file for the JDK search order, it's similar to Windows in terms of the environment variable names. It's a legacy way to adjust the boot jdk, use it for older product versions. Consider using .jdk file instead (see above), so that your modifications can survive IDE updates/re-installation.
Check this answer if you need to install the JDK manually on Linux.
If you have problems with ugly fonts, please see this thread comments for the tips.
Help | About will show the actual JDK version.
Mac OS X
Our latest IDE versions come with the bundled custom JDK 8 which contains the fixes for most known OpenJDK bugs. Should you need to use a different Java version, please refer to https://blog.jetbrains.com/idea/2015/05/intellij-idea-14-1-4-eap-141-1192-is-available/.
If you override IDE JDK version, its path is stored in .jdk file located in the config folder (idea.jdk for IntelliJ IDEA, pycharm.jdk for PyCharm, etc). Delete this file or change the path inside the file manually in case IDE no longer starts and you can't change it via the menu.
If IDE doesn't start and this file doesn't exist, create it manually and specify Java path to use (Java home location), for example:
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk
A reminder - once you set up a JAVA_HOME env variable in Windows, you need to close all your IntelliJ apps, and then start again. Otherwise, there might be troubles with accessing JAVA_HOME variable.