Which JRE version to use while making new Java Project in Eclipse and what are the drawbacks? - eclipse

In Eclipse when i create new Java Project, i see options like:
Now i want to know, what is the safest option to use considering when i export jar file any user will be able to use it. If selecting the shown option, does that mean if someone has JRE 1.6, he will not be able to run that jar file, or is it backward compatible??
As such my project has no specific 1.7 dependencies.

This is very broad question, which JRE to use depends on your requirement. If you have multiple projects, each specific to a JRE, then you can use project specific JRE. If you are happy with eclipse default JRE you can continue. It is purely your decision.
Someone with JRE 1.6 should be able to run on 1.6 as long as compilation level is set to 1.6 (This may flag if your code has any 1.7 features which are not part of 1.6).

If you use features which are specific to JDK 7 (such as the new NIO.2/The path API ) then they most likely won't work on java 6. Furthermore Java 6 has been tested and withstood the test of time as a result most (if not all) bugs have been ironed out. Java 7 is still fairly new and even after it was released there was a pesky bug that showed up couple of days after release which had to the with the loop optimisation. So unless you specifically need JDK7 features I'd suggest you stick with JDK6, on the other hand if your project is not mission-critical then you might experiment with the new JDK7 features given that your user base has JRE 7. Just my 2 cents...

Related

Javafxpackager: how do you set the "base JDK"?

When I run javafxpackager, I get the following warning/info:
No base JDK. Package will use system JRE.
It's not clear from the docs for Deploying JavaFX Applications how one would specify an alternative JDK. There isn't an option for it, that I can see (maybe I'm blind). Is it a system property?
Thanks.
There is an old Oracle blog which mentions this. Don't know if it is still applicable or relevant to your case or not though:
Self-Contained Applications: Select Java Runtime to bundle
Packager tools in 7u6 assume current JDK (based on java.home property)
is the source for embedded runtime. This is useful simplification for
many scenarios but there are cases where ability to specify what to
embed explicitly is handy. For example IDE may be using fixed JDK to
build the project and this is not the version you want to bundle into
your application.
To make it more flexible we now allow to specify location of base JDK
explicitly. It is optional and if you do not specify it then current
JDK will be used (i.e. this change is fully backward compatible).
New 'basedir' attribute was added to tag. Its value is
location of JDK to be used. It is ok to point to either JRE inside the
JDK or JDK top level folder. However, it must be JDK and not JRE as we
need other JDK tools for proper packaging and it must be recent
version of JDK that is bundled with JavaFX (i.e. Java 7 update 6 or
later).
Here are examples ( is part of task):
<fx:platform basedir="${java.home}"/>
<fx:platform basedir="c:\tools\jdk7"/>
Hint: this feature enables you to use packaging tools from JDK 7
update 10 (and benefit from bug fixes and other features described
below) to create application package with bundled FCS version of JRE 7
update 6.
When run with the parameter -Bruntime:
javapackager.exe -Bruntime="c:\Program Files\Java\jdk1.8.0_76\jre\" ...
you get the following info:
Using base JDK at: c:\Program Files\Java\jdk1.8.0_76\jre
In case it helps anyone, I wanted to use javapackager to bundle the 32-bit Java 8 JRE. I was running into issues because the JDK was the 64-bit Java 8 JDK. I was able to solve my issue by setting JAVA_HOME to the 32-bit JRE.
I have just solved same problem:
NetBeans ID - Tools - NetBeans Platform Manager - "Sources" tab
button Add ZIP/Folder
(there were no sources set so I set it and "No base JDK. Package will use system JRE."
disappeared)

How to add JDK 7 in compiler list in eclipse

I have installed the JDK7 on my machine and I want it to add in the list of compiler
I have tried adding JDK 7 in the list of installed JRE but it is still not appearing in the list of compiler compliance level.
Could any one tell me how can I add JDK 7 into new compliance level.
Eclipse uses its own compiler (see What is the difference between javac and the Eclipse compiler?), so you won't find it if you use an old version of Eclipse (as probably your RSA is based on). Java 7 support is available for Eclipse 3.7.1 or higher (at the moment current stable is 4.2).
However, if you want to keep that version of Eclipse, you can create a new Builder using your JDK7 as base. To do this, go to Project and add a new Builder specifying where the javac is and the other options.
Look also at this question: Eclipse 3.5 and Java 7
Looks like you have to use the 3.8 version of eclipse to get Java 7 support. But I noticed that some later versions of 3.7.x might have it too.
See this for features:
http://www.eclipse.org/jdt/ui/r3_8/Java7news/whats-new-java-7.html

What is the purpose of Java JDK to Eclipse?

I've just installed Eclipse, after i installed the java JDK.
The Getting Started guide (in Eclipse) says i should reference my JDK installation in Window>Preferences>Java>Installed JREs, but that a JRE would also work.
Select the Java > Installed JREs preference page to display the installed Java Runtime Environments. Confirm that a JRE has been detected. By default, the JRE used to run the workbench will be used to build and run Java programs. It should appear with a checkmark in the list of installed JREs. We recommend that you use a Java SDK instead of a JRE. An SDK is designed for development and contains the source code for the Java library, easing debugging.
There was already a JRE set up there (not a JDK), so i did nothing and tried to compile a Hello World (just to see what would happen). To my surprise, it compiled!
I searched a little bit and it looks like this works because Eclipse has a built-in Java Compiler. I tried debugging using the same eclipse set up, and it was also successful.
So, what is the difference between setting a JDK and JRE there? Why is it important to download the JDK, since in my default configuration Eclipse doesn't seem to use it?
Probably the main difference is you get the source to all of the Java runtime libraries (with the JDK) which can be a big help. I always use the JDKs for that reason.
Also if you are debugging, this will allow you to meaningfully step into Java runtime libraries.
There are a number of tools that come with the JDK that don't come with the JRE - JConsole (http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html) springs to mind. This for example can help you understand & monitor the memory usage of your application and so on. Either way if you head into unfamiliar territory, I highly recommend you follow the Eclipse suggestion and use the JDK!
JDK is equipped with different helpful tools, as DotMasta mentioned. Eclipse's "version" of JDK is called JDT. Apart from range of shipped tools, there are also differences between javac and Eclipse built-in compiler ecj, so check here to see the comparison. One of the most important differences is that javac is strict, i.e. with ecj you can create a class file even in case of errors in code, which is perfectly suitable for testing phase, but not for launch :)
JDK contains software development tools which are used to compile and run the Java program.
Plenty of classes and methods in standard jdk library
Javac java compiler
Diffrences and why you will need this?
JDK includes the JVM, standard class libraries, and several other tools that a developer needs in order to create a Java program.
JRE includes the JVM, as the JRE provides some standard libraries and the JVM which can be used to execute a Java program.
You can even look there: http://en.wikipedia.org/wiki/Java_Development_Kit

Check project for use of code introduced in Java 7

On my development machine, I have JDK 1.7 installed, but we are packaging software for use with Java 1.5 and 1.6. It's easy to set the -source and -target options so that the syntax is forced to be a particular version, and the output class is interpretable by a particular VM. But there are other version-isms that are biting me, like the 2-argument constructor AssertionError(String, Throwable) and various other subtle changes.
The one solution I know of is to install every different JDK (1.5, 1.6, 1.7) so that Eclipse can exactly match the execution environment for me. Is there any other way to detect these problems? Bonus points if it's an Eclipse or Maven tool.
How about the Codehaus anmial-sniffer maven plugin? I haven't had reason to try it yet, but thought it looked interesting.
does this tool help? It's command line, I have seen people using it to detect java7 being used.

Does XText require minimum versions of Eclipse or Java

While I can just try and run it and see if it fails I may not know if some internals will fail at inopportune times does anyone know if specific versions of java or eclipse are needed?
I'm sure, no special version of Java nor Eclipse is needed. It needs Java 1.5 and some Eclipse Modeling components (such as EMF); but they are already installed with Xtext.