I have Java 7 running on my mac:
System.out.println(System.getProperty("java.version")); // prints 1.7.0_05
Project was created using
Project properties confirm, i am on Java 7
Default system Java is 7
The following however results in syntax error
public static void main(String[] args) {
// Underscores in Numeric Litarals are ok here
int i = 11_234;
}
Eclipse is complaining with Syntax error on token "_234", delete this token
On Eclipse's Project|Properties dialog, there two entities Java Build Path and Java Compiler. The former will tell you what classes are used during the build, and you may have a Java 7 JRE listed there. The latter, however, is the compiler that will be used to compile your code. It is possible to have Eclipse use a Java 6 compiler even with a Java 7 JRE on the build path.
My guess is that you are using Helios, not Indigo. See Programming Java 7 in Eclipse
Make sure your version of Eclipse is 3.7.1 (this is Eclipse 3.7 Maintenance Build) or higher (see JDT/Eclipse Java 7 Support) and that you have registered Java 7 with Eclipse (see Eclipse and Java 7).
Related
I have two JEE applications, one runs under Java 8, the other runs under Java 11.
Is there a way to force each application to use the good Java version when I run it (via java -jar xxx.war)? Or do I need to update the Path environment system each time?
My issue is that Java 8 application cannot run with Java 11 because it generates the exception
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
(which is not supported in Java 11).
you could do something like this :
export JAVA_LATEST=/usr/local/jdk1.8
export JAVA_OLD=/usr/local/jdk11
in $HOME/.bashrc
JAVA_HOME=$JAVA_OLD
in shell launcher of your JAVA 8 app
JAVA_HOME=$JAVA_LATEST
in shell launcher of your JAVA 11 app
Getting the following sync error while trying to build my first helloWorld program in IntelliJ.
I've installed IntelliJ for the first time on my computer running Windows 10.
Could not open init generic class cache for initialization script 'C:\Users\nikhils\AppData\Local\Temp\wrapper_init5.gradle' (C:\Users\nikhils\.gradle\caches\6.6.1\scripts\2xaig2b083uxqwleg0fdntova).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
Change project and Gradle JDK to the supported version (8—15). Current Gradle release versions do not support Java 16. You would need Gradle 7 if you want to use Java 16.
The easiest way would be to create a new project with Java 11.
Also note that full Java 16 support will be available starting from IntelliJ IDEA 2021.1 release (current release version is 2020.3.3).
See https://www.jetbrains.com/idea/nextversion/ if you want to give it a try.
Other developer had pushed the code and we are building it on a build machine.
I was getting Unsupported Major.minor version 52 error.
Is there any way to find the version of JDK used while developing the Java file.
Could some one please help
By developing you probably mean compiling the java file.
Take the .class file and look inside it with javap:
javap -c -verbose ConstructorReference.class
Output (at the beginning of the output)
public class org.ConstructorReference
minor version: 0
major version: 53
53 - means java 9
52 - means java 8
You get the error because the build machine is using most probably jdk-7 and your class files were compiled with jdk-8 (evidence of 52).
I am trying to compile my application with java 9 and it is failing because
native2ascii executable is not there. Has it been removed in Java 9? Is there another tool that does the same thing?
Yes, native2ascii was removed in Java 9. From the bug report to remove it, "JEP 226 proposes to support UTF Properties file that will address the original motivation of creating the native2ascii tool." For more information visit JEP 226.
I'm using the ZIP distribution of STS 3.5.1 for win32.
I start STS with this cmd script:
set JAVA_HOME=d:\jdk\jdk1.7.0_21
set PATH=%JAVA_HOME%\bin;%PATH%;
start .\sts-3.5.1.RELEASE\sts.exe
Then, when I do "New > Spring Starter Project", I get this error:
If I replace Java 7 with Java 6 by changing the first line of my cmd script, everything works fine: the wizard starts.
set JAVA_HOME=d:\jdk\jdk1.6.0_31
Is there something special to do if I want to use Java 7 ?
You probably want to get a more recent version of the JDK 1.7 (e.g. 1.7.0_51) as there were quite a few unpleasant bugs in earlier releases. Otherwise I don't have any suggestions. Can you see the service (http://start.spring.io) from your browser?