Can somebody tell me what are all the places where I have to change the java version, because I have changed it in more than 5 places so far (I don't even remember all of them) and it is still saying "diamond operator is not supported in -source 1.5". The most stupid ide ever..
Project -> Project SDK
Project -> Project language level
Modules -> Language level
Project bytecode version
Target bytecode version
If you use Maven in IntelliJ IDEA to build your project you have to set Java version as parameters source and target in configuration for maven-compiler-plugin:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Default version for this is 1.5 and IDE use it to check source code compatibility.
Related
I just finished a program "Maven java project". I am using Jersey library/.
I need to compile and run my program in java 1.4.
I am changing the compliance to 1.4 in Eclipse.
plus adapting the pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.4</target>
</configuration>
</plugin>
</plugins>
Now I am getting errors concerning certain classes:
Any help would be much appreciated!!!
Jersey is not compatible with Java 1.4. Neither is the <> syntax. You really should at least use java 1.6.
Where is IJ picking up the language level ?? When compiling I am getting the following error:
Error:(29, 38) java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
Note: the pom.xml has NO mention of the java level.
But from screenshots we see FOUR places I have selected 1.8 !
place following in your pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
IntelliJ respects's maven pom.xml's configuration, by default points to JAVA_HOME and which might not be set properly, So setting compiler version to 1.8 does the job here
Try Settings > Modules > {module} > Dependencies > Module SDK.
Please see screen shot attached.
I'm using java 7 to compile my class files using maven /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java, but still i'm getting below errors. What might i be doing wrong ?
Compilation failure:
error: generics are not supported in -source 1.3
error: annotations are not supported in -source 1.3
IntelliJ preference > Java > Compiler > Set language level to 1.7
Project > properties > Project language level > Set language level to 1.7
You have change your pom file:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
I am aware that similar questions has been asked in the past, but I couldn't found my answer in it.
I am using Eclipse Luna and upgraded to java 8 (build 0.25).
The JAVA_HOME points to java 8 and also it's part of the Windows Classpath.
After the upgrade, maven compile shows some Ambiguous method calls that didn't show up in java 7.
The problem is that these errors aren't shown in Eclipse and I can't find why.
I removed all jre's in eclipse and removed/added the java 8 jdk, but still no luck.
Also Eclipse is using the java 8 environment for compiler errors/warnings.
With maven I use the "plexus-compiler-javac" compiler, snapshot 2-4. I also tried without the plexus compiler and with version 2.0, but no luck.
Any idea what this could be?
My Pom snippet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<!--version>2.0</version-->
<version>2.4-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<fork>false</fork>
<encoding>utf-8</encoding>
<meminitial>256m</meminitial>
<maxmem>1024m</maxmem>
</configuration>
</plugin>
Try telling maven to use java 8 source level by adding/changing configuration of your compile plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
i face this issue with tools.jar not found, so download the latest tools.jar & copy to D:\Java\jdk1.8.0_25..\lib\tools.jar, thanks.
I am using maven2 to build the java project, when i issue the command mvn clean install i am getting the error could not parse error message: (use -source 5 or higher to enable generics).
In my eclipse environment i am using jdk 1.7 and the project is working fine. when i want to build the project i am unable to do that, think maven is taking java version 1.3 as default.
Any one please help me how to set the jdk versio to 1.7 in maven, to build the project successfully..
Apart from the jars mentioned in pom.xml i want to add add my own jar, how can i specify that in pom xml?
Thanks in advance..
In your pom.xml configure the maven-compiler-plugin to use 1.6:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>