What features would I go to miss if JDK is not installed? - java

I would like to know if JRE is installed in my computer but not JDK, then what features am I going to miss?
I have faced this interview question recently. I am seeking for it, but could not found answer searching in Google and some other places.
Thanks Sir.

The JRE comprises the JVM and a few tools. You might be mixing this up with the difference between the JRE and the JDK. "JRE" means "Java Runtime Environment", which means the JVM, which means the "Java Virtual Machine". "JDK" means the Java Development Kit, which is everything in the JRE (including the JVM), plus additional tools like the compiler "javac" that allow you to create Java code.
In short, the JRE is what you need to run Java code, including the JVM, and the JDK is what you need to write Java code.
This is covered in the documentation for Java, which I recommend that you read.

The JRE is used for execute java aplications (when the software exists). JDK is used for software developers (for create a new software).

you can see the answer about having only JRE in JRE included with JDK vs. standalone JRE this link,you will see that If you installed only JRE,then you will lack the tools included with the JDK (JavaDB, javac, tools.jar, etc).

Related

how to find duplicated libs and version conflicting classes using Memory Analyzer Tool

IS Memory Analyzer Tool allows to find duplicated libs, classes and version conflicting classes present in the given input application
See this if it helps and I Didnt use it though
http://community.bonitasoft.com/effective-way-fight-duplicated-libs-and-version-conflicting-classes-using-memory-analyzer-tool
It seems there was a problem with different Java versions.
A long story short: If JDK is outdated re-install it, and delete Java executables from C:\Windows\System32 and C:\Windows\SysWOW64.
Firstly, I want to tell you that I have multiple versions of Java on my computer. My JDK is 32-bit because of some drivers not running with 64-bit Java. Also, I have both 32-bit and 64-bit JRE installed, the latter for better performance for Java games.
My JDK was version 7, update 40. The VisualVM was so also that version. However, my JRE with auto updates was version 7, update 45.
java -version told me it was version 45 (which it was), so I didn't think the problem was there.
Then, I checked the versions via Control Panel. I now knew my JDK was outdated, so I uninstalled it and redownloaded it.
Uninstalling removed Java from the system path, so jvisualvm wouldn't run. I added it to the path. Now both the app and VisualVM ran normally, but still the problem persisted.
The final problem was that the system was using the java.exe from C:\Windows\System32 instead of the JDK one. By the date it seemed to be the latest one, but maybe it was that the JRE was installed in a different location that the VisualVM (= the JDK).
Finally, I just deleted the Java executables in both C:\Windows\System32 and C:\Windows\SysWOW64.

Eclipse compiling with JRE or JDK

I have one question in my mind and I should note that I know the differences between JDK and JRE. I am not a new programmer in Java.
What I would like to ask is in Eclipse I can specify the compilation environment (correct me if I a wrong) in window> Preferences but we can also change it for a specific project.
OK. I added jre and jdk folder in the options. I can use both.
But JRE has no javac (no java compiler) in it. So how it is possible that some projects requires that I need to change to jre1.7 to COMPILE?
I was getting some minor.major version error and setting JRE solved my problem?
How can this be possible?
In fact now I realized something.
Ok the question changes a little.
I saw that these are VM not compiler. I understood.
Does JDK have also JRE in it? so if I specify JDK1.8 I am setting jre1.8 as VM and if I specify JRE1.7 I am setting jre1.7 as VM?
Is it right?
It makes confusions. Why JDK has JRE in it?
JDK has whole JRE (regular Java VM) inside, in order to allow you to run what you will develop with it.
Theoretically someone could make some small-JDK with just tools and without JRE, but it would make a whole lot more confusion as to which tools version run with which JVM version (most JDK tools needs JVM to be run). Look at you, how many people have only this problem? So it is bundled together, tools and JRE as a whole named JDK, thanks to that you have some guarantee that those JRE and tools will work together.
JRE - Java Runtime Environment - allows you to run java programs
JDK - Java Development Kit - allows you to run and develop java programs
JDK = JRE + tools for developer
Also note, that You can choose for the java compilation process two things:
compatibility with source version - this is basically the syntax you are allowed to use.
compatibility with VM version - this is the minimum VM level on which you can run the compiled binaries.
example from your post: If you have compiled something as Java 8, you can't run it on Java 7, this is the minor/major version problem you have. But the opposite (to run something for Java 7 on Java 8) is valid.
in your example JDK8 and JRE7 both are just fully functional VM's, but JDK8 has additionally (in comparison to JRE) development tools inside it.

Can I have two versions of the JDK on my computer?

I'm trying to set the IntelliJ IDEA JDK to version 1.8 (because it's the latest). When I navigate to System/Library/Frameworks/JavaVM.framework IntelliJ IDEA shows 1.6. When I type java -version it shows 1.8. I found that command under "Finding default JDK on OSX" https://www.java.com/en/download/help/version_manual.xml
I'm confused what versions of the JDK I have... and where they are located. Appreciate any help.
Yes, you can. You have JDK 1.6 and 1.8 installed on your computer. According to the Jetbrains website, all their products require Apple JDK 1.6 to be installed in order to run on Mac.
To make IntelliJ IDEA use JDK 1.8, you will need to edit /Applications/<Product>.app/Contents/Info.plist file and change JVMVersion from 1.6* to 1.8* :
<key>JVMVersion</key>
<string>1.8*</string>
To start off java will usually uninstall any version of the JDK when you get an update. Secondly if you want to check to see what version you are running I would go into what ever you are using to program and see what version you are compiling under (For example netbeans or eclipse). If it says 1.8 that is what you are running and same for 1.6. If this is really becoming a super big problem all you have to is uninstall java then re install and it should fix it.
You can have many different versions of Java on your system. In general Java depends on environment variables and the PATH environment variable. Some programs and tools look for tool specific environment variables to allow you to use a specific version of Java for that particular tool.
In the case of IntellJ the link that Eddie B posted in his comment explains how IntellJ determines which "installation" of Java it should use.

JRE included with JDK vs. standalone JRE

What's the difference between the JRE included with the JDK (located inside of the jre folder) and the standalone JRE? Is there any?
The "standalone JRE" (sometimes also referred to as the "Public JRE") generally does not contain the server version of HotSpot. It also lacks the tools included with the JDK (JavaDB, javac, tools.jar, etc).
Otherwise, the runtimes are identical. Also, note that a JDK may install one (or more) JREs.
Finally, all of the above notes are in regards to Sun's Java installers for Windows. Other vendors and platforms may (and sometimes do) vary.
There is no difference (unless you have a different version of the JRE). Here is the official definition from SUN/Oracle:
http://java.sun.com/javase/6/docs/technotes/guides/index.html
JRE and JDK Sun Microsystems provides
two principal software products in the
JavaTM Platform, Standard Edition
(JavaTM SE) family:
Java SE Runtime Environment (JRE)
The JRE provides the libraries, Java
virtual machine, and other components
necessary for you to run applets and
applications written in the Java
programming language. This runtime
environment can be redistributed with
applications to make them
free-standing.
Java SE Development Kit (JDK)
The JDK includes the JRE plus
command-line development tools such as
compilers and debuggers that are
necessary or useful for developing
applets and applications.
If you run a binary compare against the standalone JRE and the JRE included in the JDK they are binary different (at least in Windows version).
The class count in rt.jar is equal but out of curiosity, I ran 'javap' on all classes in both and compared results.
The only difference I see is that the JDK verison has lines like 'Compiled from "Serializable.java' before the class code.
I don't think this should have any impact on end user, so these JREs should be in fact behaving the same way.
The difference is legal. JDK is for development, JRE is for execution. You can include JRE with a product
The "JDK" is the Java Development Kit. The JDK is bundle of software that you can use to develop Java based software. The "JRE" is the Java Runtime Environment. The JRE is an implementation of the Java Virtual Machine which actually executes Java programs.
Typically, each JDK contains one (or more) JRE's along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.

java jre confusion

Could anyone please tell how jre directory help in the running java programs? I'm calling java interpretor by using java command, and that is in JDK directory, then how could jre directory help in running java programs and jdk for compiling?
When you install the JDK (development kit, compiler and so on), you get the JRE (runtime environment) as part of that (under my install, there's actually a jre subdirectory in the jdk folder) - this is because you will probably want to run code that you develop if only to test it a little bit before inflicting it on the rest of the planet :-).
But it's by no means necessary to install the JDK to run Java programs. All you need is the JRE and that is, by far, the normal situation for most people out there.
The JRE is just the interpreter (java.exe or whatever) - it's a smaller install that is typically used by people who just need to run Java applications and aren't Java developers. The JRE handles the conversion and execution of java bytecode for the target platform.
The JDK is meant for developers. Along with the runtime it provides the compiler and all the Java libraries that are used to build Java programs. The compiler is responsible for converting Java source code to bytecode.
So - when you are delivering your Java application to customers, all they need to install is the JRE.
The Java Runtime Environment (JRE) interprets byte code to platform specific machine code. JRE is minimal set of programmes which executes the java class files.
The JDK (Java Developmental Toolkit) comes along with java libraries and JRE embedded in it. Apart from these it comes along with the utility tools for byte code compilation "javac".

Categories

Resources