views:

283

answers:

2

Hi, I have a confusion that what JRE is doin on the Background and what does the JDK doing.

+16  A: 

JRE: Java Runtime Environment. It is basically the Java Virtual Machine where your Java programs run on. It also includes browser plugins for Applet execution.

JDK: It's the full featured Software Development Kit for Java, including JRE, and the compilers and tools (like JavaDoc, and Java Debugger) to create and compile programs.

Usually, when you only care about running Java programs on your browser or computer you will only install JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you will also need JDK.

Sometimes, even though you are not planning to do any Java Development on a computer, you still need the JDK installed. For example, if you are deploying a WebApp with JSP, you are technically just running Java Programs inside the application server. Why would you need JDK then? Because application server will convert JSP into Servlets and use JDK to compile the servlets. I am sure there might be more examples.

Pablo Santa Cruz
Then when we are using external jars, we are deploying those jars in jre/lib/ext/.. So why that??
i2ijeya
There are a few jars specifically intended as extensions of Java; those can and should be placed in lib/ext. But putting any old application jars is not what this directory is intended for; it's an abuse of the extension mechanism and may cause problems later on.
Carl Smotricz
I have worked on JExcel API and I've set the classpath correctly and still there exists the problem. So i deployed it inside tlib/ext folder, which woks fine after that?? So what would be reason??
i2ijeya
I don't have information to be completely sure, but my guess would be that either you didn't really set the classpath correctly, or you set the classpath for a different classloader than the one that ended up using your code. What makes lib/ext different from classpath extension is that lib/ext will affect *any* java app that uses that particular JRE - it's more foolproof than setting the classpath.
Carl Smotricz
+1  A: 

Pablo is very right. This is just additional information:

"The JRE" is, as the name implies, an environment. It's basically a bunch of directories with Java-related files, to wit:

  • /bin with executable programs like java and (for Windows) javaw, which are essentially the program that is the Java virtual machine;
  • /lib with a large number of supporting files: Some jars, configuration files, property files, fonts, sounds, icons... all the "trimmings" of Java. Most important are rt.jar and a possibly a few of its siblings, which contain the "java API," i.e. the Java library code.
  • Somewhere, possibly squirreled away by the installer to some directory specified by the operating system, are some .DLLs (for Windows) or .so's (Unix/Linux) with supporting, often system-specific native binary code.

The JDK is also a set of directories. It looks a lot like the JRE but it contains a directory (called JRE) with a complete JRE, and it has a number of development tools, most importantly the Java compiler javac in its bin directory.

Carl Smotricz