Java core API part of JDK or JRE? - java-8

I want to know whether the official Java core API is part of JDK or JRE.
According to my understanding of Java, I think that the core API should be part of the JRE, as the application should be runnable without the additions provided by the JDK.
I also found some information on the web that says the 3 basic components of the JDK are,
Java Compiler
JVM
Java API
(As the JRE is the implementation of JVM, does the Java API belong to JRE or JDK?)
Edit: actual question: Is the Java API included in JRE?

Your facts are a bit inaccurate.
I also found some information on the web that says the 3 basic components of the JDK are: 1. Java Compiler, 2. JVM, 3. Java API.
That's not a good summary. There are certainly other things in a JDK apart from that.
As the JRE is the implementation of JVM
In fact the JRE includes an implementation of the JVM. And it also includes the core Java APIs, and a few other things.
As Holger points out, a JDK consists of a JRE plus some additional Java development tools. Or as he succinctly puts it:
"JDK = JRE + development tools"
So to answer your question:
does the Java API belong to JRE or JDK?
The Java APIs are included in both a JRE distribution or JDK distribution, but the phrase "belong to" doesn't have much meaning in this context.
(Now one could debate whether a JDK "contains" a JRE (or not), and whether the JRE "contains" the Java APIs. But to be honest it is a pointless debate. What really matters is that the Java APIs are present in both kinds of distribution.
Also, this is substantially moot in Java 11, since Oracle no longer provides JRE distributions for either Oracle or OpenJDK Java. It is now JDK only.)

A picture is worth a thousand words.
However, please note, the above diagram reflects the structure of JDK 8 and for later editions it is different.

Related

Clojure dependency on Java 1.5 only?

I hope this is not off-topic for SO (I hesitated between SO and programmers.stackexchange) but as far as I can tell this is a "practical, answerable problem that is unique to the programming profession" so it's complying with the FAQ.
Which version of the JVM do you need in order to run which version of Clojure (Clojure on the JVM, this question is not about ClojureScript)?
The page here: http://clojure.org/getting_started states that:
Clojure requires only Java 1.5 or greater
But is this always going to be the case?
And what about the Clojure ecosystem, like Leiningen?
Basically I'd like to know if I can count on Clojure to be able to develop a desktop app that should run on systems, including OS X systems, that are never going to get Java 6 nor more recent versions of Java (for example on some OS X versions Apple stated that no JVM 6 would ever see the light).
I am not on the Clojure/core team, so I don't have inside information, but here is how I would approach this situation.
Take the latest version of Clojure (1.5 as of this writing) and test it against Java 1.5 for the things you need to do and any Clojure libraries you need to use and stick with that. If Clojure 1.5 is Java 1.5 compatable, it will always be so, since that release is immutable.
I would not make the assumption that all Clojure versions after 1.5 will be Java 1.5 compatible and you definitely can't assume that Clojure libraries will be. For example, I just released a Clojure library that requires Java 1.7 (since it uses a java.util.concurrent class introduced in Java 1.7).
Since Leiningen gives you maven-like dependency resolution if you test all your libraries and your chosen version of Clojure against Java 1.5 and they work, then you can stick with that set of versioned dependencies for as long as you want to keep the app running. Your only risk at that point is that some bug fix releases of a non core library might not be Java 1.5 compatible any longer. This risk is proportional to how many non-core Clojure libraries you need to use.
If you are selective about what libraries you use, then targeting Java 1.5 is certainly feasible.
Clojure is very conservative about it's Java version requirements - hence the dependency on version 1.5 only.
Many libraries depend only on Clojure itself, so will run quite happily on the 1.5 JVM
Some libraries require >1.5, these tend to be more advanced libraries that have requirements for interop with specific Java features (e.g. newer concurrency code).
Note: I personally write all my apps/libraries to target Java 1.6, since I think that is a reasonable minimum and the vast majority of Java-based systems are at 1.6 or above. I'm willing to live with the potential loss of a few users who are stuck on 1.5. Also, even if a future version of Clojure does abandon 1.5, I expect it will continue support for Java 1.6 for a long time.
Notably, in Clojure 1.6 they have bumped the version of Java to 1.6:
The Clojure 1.6 Release Notes
include this ticket:
CLJ-1268: Require Java 1.6 as minimum for Clojure
So, "no" is the answer to the original poster's question of "But is [Clojure requires only Java 1.5 or greater] always going to be the case?"

Shipping JRE 8 Early Access Releases

I used jdk8 to compile my java program to use some latest feature.
Can JRE 8 be shipped before final release ?
Looks like JRE 8 is not available standalone.So can I ship JDK8 before it it's final release
JRE8 and JDK8 are currently in Early Adopter version (EA). It's license terms follow: http://www.oracle.com/technetwork/licenses/ea-license-152003.html
We grant You a revocable, nonexclusive, nontransferable, royalty-free and limited right to (a) use one (1) copy of the binary portions of the Programs and any Supplemental Programs for the sole purpose of internal non-production and non-commercial evaluation and testing of the Programs, including, developing no more than a single prototype of each of Your applications;
Now, of course, I'm no lawyer nor is this legal advice, but as this says, you can't ship a jre8 software (as that would include binary portions of jre8) to your production or commercial non-evaluation nor testing multiple non-prototypes of your application.
Additionally, you'd be subject to their Export Controls, found in the above address.
The GA is available as of March 18th:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Bundling a JRE with an application?

I've been debating whether or not to bundle a JRE with my application. I've listed some reasons below why I think it would be useful, but I'm also hesitant to do this because it makes the app much larger.
Why I think it would be useful:
Right now the app is run by running a batch file (well, a shortcut to a batch file, it is run via a batch file). It just calls java -jar XXX, which requires Java to be in the path, which is not always the case.
We're a small team and not fully running on Java 7 (there are some strange errors we are trying to debug still). If a user has Java 7, they may have an unpleasant software experience - this is not good for us. Packaging a specific version of the JRE ensure we've fully tested on it.
We support 32 and 64 bit Windows platforms. When the user downloads the software, they choose 32 or 64-bit, but this is asking which version of Java are they using. Most users don't know if 32-bit java is installed on their 64-bit platform, and it can be confusing to download 32-bit even though their OS is 64-bit.
There are some good reasons why not to package it though:
If a security hole is in Java or other significant updates are made to the JRE, we need to distribute a new version of our app with a new Java version. We are generally updating our app every couple of weeks, so I'm not too concerned about this one right now.
The app will now be much larger because it includes a packaged JRE.
Can anyone provide some guidance as to whether or not (based on these requirements) they think it is a good idea to package the JRE? If not, what are some alternatives to just hoping that java is in the path (and more importantly if it's not, it is possible our users may not know how to add it).
Java Web Start. The JRE will be on the path.
For version control, see Java Web Start - Runtime Versioning & particularly Earlier Version.
JWS can partition resources between a 64 bit & 32 bit JRE.
So, 'bad idea to bundle JRE'. Use web-start instead.
I would suggest to NOT bundle the JRE although I often see it as a common practice.
Instead I would either use webstart (can be used offline as well) or some other installer or pacakge manager solution that ensures that Java is installed including the correct version. This will widely depend on the operating system you expect to run on.
Going down the way of including Java begs the question what else you want to include, just to be sure... which will lead you to the whole operating system and everything needed thought to the end.
I would also suggest to closely look into what types of users will install the app and adapt to that and make some sort of estimate on how capable they will be.

Tomcat native library benefits

Can anyone advise on the main benefits of installing the Tomcat native library?
I am running a standard installation of Tomcat to serve a moderately complex intranet based web app using Ext Js on the front end so lots of javascript and AJAX over the network and VPN from various locations.
Is it even worth installing this library for the comparatively small amount of requests it will be getting.
The app can be very slow at times and I'm looking to boost performance. I am already refactoring Java code based on profile data but as the problem seems to be more generalised I am also looking at the app server configuration and I can't seem to find any detail on whether this library would actually benefit me in this scenario.
Thank you
I assume you are speaking about Tomcat APR. I personally don't believe that by simply switching the connector from non-native to native will automagically solve your performance problems.
Unless you have exercised all code inefficiencies (it seems that you are doing this already with the help of profiler) and solved them, it is probably not worth it.
I would envisage that APR helps in cases where most of requests are static and delivering static content becomes a bottleneck. To achieve this, you probably need to be delivering millions pages per day and having thread pool going through the roof (which I assume is not likely for your intranet).
Some of tomcat apr is not found in ubuntu repositories as they are no longer supported.
Please make sure these configurations are correct:
In eclipse under windows->preferences->servers-> runtime environment,
choose the server where your project is deployed. Select the option installed jre and choose the java version you have installed or one you prefer.
Under project properties -> runtime environment select the server and press apply.
Under build path double click on jre library and choose the java version you have installed.
Native libraries are required when there is a mismatch between the code in the project in the jre version or the tomacat version.
Make sure that in your build and code, both are for the latest version of servlet that tomcat supports and jre is at its latest version that tomcat supports.
For example, if tomcat v8.5 supports java version 7 or above, you should have java version latest above 7 and tomcat v8.5 supports servlet version 3.1 so in your build set up. Make sure to use a container that uses servlet 3.1.

Is it "safe" to develop for the JDK7 platform?

We have a project which (assumed) would be finished in 1-2 years. By then, the JDK7 (and hopefully the Java7 JCP spec) should be ready.
But, I wonder, how probable is the "danger" that Oracle will make a "stupid" decision, which would make the JDK7 a less "attractive" platform then the existing JDK6?
More specific, I'm afraid of scenarios such as:
halting the development of JDK7 before it is "released"
changing the licensing model to be more restrictive than JDK6
...are there other scenarios to be aware of?
What is your opinion on the issue?
NOTE: We would use the NIO2 files API, and perhaps other JDK7-only features which were accepted for "Plan B" (Plan A was rejected, was a proposal to continue to develop JDK7 much longer, instead, Plan B was accepted: develop JDK7 with less features and postpone them for JDK8)
It depends on how many Java 7 specific features you use.
If your code can still compile on JDK 6, I'd say you're quite safe. You can run on JDK 7, since it's backwards compatible, but if there's an issue you can still deploy on 6.
If Oracle does something really stupid you'll have a bigger decision on my hands: Do I rewrite this app in C#, Python, or something else?
I'll be curious to see how well open source JDK will allow you to hedge your bet.
I'd also be curious to see which features of JDK 7 you're already using: closures?
If you're concerned about risks associated with Java 7, you can mitigate them by ensuring your code will run on Java 6. The easiest way to do this is to develop atop Java 6 now, then upgrade to Java 7 once those risks have dissipated.
In addition to the risks you've noted, the set of features planned for Java 7 is in flux.

Resources