How to add JDK 7 in compiler list in eclipse - 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

Related

Does Eclipse Neon support Java 9?

Does Eclipse Neon support Java 9? I know Eclipse Oxygen can be used but we have some constraints to not use other Eclipse than Neon.
We are using Maven for Building our J2EE project and Git for source control.
I appreciate if you can back your answer with some links/proofs. Thanks!
Does eclipse Neon support Java 9?
It depends what you mean by "support". If you mean "Is the use of Java 9 officially supported with Neon?" then the answer is no. For example, see this DZone article:
You need an Oxygen-based install of Eclipse – ensure you’re using the
R version and not milestone or integration builds.
Also, from Eclipse's site:
Users who install Eclipse Oxygen 4.7.1a are able to launch with Java 9
and get Java 9 support
But if you mean "Is it possible to get Java 9 running under Neon?" then the answer is yes. Here's a snippet from an article titled Eclipse Java™ 9 Support (BETA) for Neon from a brave soul who did it back in 2015!...
I downloaded the early access version of Java 9 JDK from java.net in
the form of a tar.gz file that I decompressed into a local directory:
/home/apps/jdk1.9.0. I made no other changes to my system.
I downloaded the Eclipse SDK 4.6 (Neon) M2 from the Eclipse Platform
downloads and decompressed it into its own directory. I made a small
change to the eclipse.ini file to make the new configuration run using
the Java 9 runtime...
Of course, that was done with an early access release of Java 9, and I wouldn't automatically assume that Neon will still work with the latest release of Java 9.
~~~~~~~~~
Update:
I just noticed this SO question titled Neon: how to run on jdk9? which may offer further useful information.

Can't get Eclipse Kepler CheckStyle plugin to work

I am downloading it from here: http://eclipse-cs.sourceforge.net/update/
- Checkstyle version 6.2.0.20150
My eclipse build is: 4.3.2
I have tried downloading it from both the marketplace and the website above, though both ways do not create a "checkstyle" link in the preferences window.
Anyone have any idea what's going on here?
I've also encountered the mentioned problem. But the reason is simple. In the release notes we can read:
Please note that as of this version Java 7 is the minimum runtime
environment supported. This requires you to run Eclipse on a Java 7
(or newer) JVM in order to use this plugin version.
Checkstyle since version 6.2.0 (released in January 2015) needs Java 7 as the minimum runtime environment.
So in order to run Eclipse on a Java 7, you can for example edit eclipse.ini file and add at the beginning something like:
-vm
C:\Program Files\Java\jdk1.7.0_75\bin\javaw.exe
Your exact path to javaw.exe could be different, of course. Alternatively make JDK 7 (or newer) as the default JVM for your system.

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)

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

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...

Why do I still get errors using a switch statement with strings in Java SE7 on Lion?

I am running Mac OSX lion and have a Java project in netbeans where I would like to use string switch statements. I downloaded and installed the OpenJDK7 and I think I have configured the project to use the Java 1.7 properly.
In the Project Properties I have set JDK 7 to the platform:
It is showing up as JDK 1.7 in the Libraries section in the Projects Window.
However, I still get a compilation error saying that switch with strings is not supported in 1.6
Am I missing a step here?
To fix this, I followed the very comprehensive tutorial from the netbeans website found here:
http://netbeans.org/kb/docs/java/javase-jdk7.html
Specifically I had forgotten to set the Sources/Binary Format to JDK 7. You can do this in the bottom right of the Sources section of the Project Properties window.
If it's anything like Eclipse, the string case is a language feature, not a library feature.
Eclipse uses its own internal compiler by default and I suspect NetBeans is similar.
So you have to ensure you're using a JDK7 compiler. From a cursory search, the project settings should allow you to set an external compiler.
Are you using 7.0.1 or greater?
NetBeans 7.0.1 provide a hint if you have a chained if-else statement to take advantage of the JDK7 features. Have you downloaded it yet ? Check out screencast #35 highlighting Project Coin features in NetBeans. NetBeans 7.0.1 provide complete tooling around JDK7 and GlassFish 3.1.1 allow you to leverage JDK7 features in your Java EE 6 applications.
http://blogs.oracle.com/arungupta/entry/totd_168_string_switch_statement
Here are some steps:
Select the project you want to change source settings for.
Got to File > Project Properties...
Select the Sources Category.
Change the Source/Binary Format dropdown to whatever format you want to use.
Viola!