maven package with jdk 6 - java

oh my god, isn't it fun to compile old code...
The problem now is compiling old war with jdk6
running mvn clean package will produce following error:
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
Sure, i understand its bit old but this application wont compile with jdk7 ...
i have tried using targets in pom.xml
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
inside properties and then separately
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Any combination of these will give same error, or im doing something wrong...
I've already had hours of fun looking packages for JDK 6 today. Please send help

Related

Intellij Java version

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.

Error compiling Jersey library different Java version

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.

Compile errors with Maven but not in Eclipse after upgrade from java 1.7 to 1.8

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.

Using Java 7 with official Google Appengine Maven plugin

I'm having trouble using the official Maven Plugin and Java 7 with Google Appengine.
Configuration
My project configuration pom.xml is quite simple:
In the properties section I configure:
<gae.version>1.7.4</gae.version>
And later on I use the plugin:
<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>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
</plugin>
Error message
Whenever I run mvn appengine:update I get the following error:
Unable to update app: The application contains Java 7 classes, but the --use_java7 flag has not been set.
My attempt to solve it
Of course, I tried to fix this issue. Running
mvn appengine:update --use_java7
or
mvn appengine:update -D--use_java7
didn't help, because the flag is not used for the Maven plugin, but instead for the appcfg script.
How do I pass the flag to the script, so that I can use Java 7 (or is there anything else I can do)?
App Engine Java 7 Support is currently for Trusted Tester and not available to public yet, you can apply Trusted Tester at here.
Fortunately the latest official maven plugin does implement this feature, see the AbstractAppCfgMojo.java:
... ...
/**
* Use the App Engine Java 7 runtime for this app.
*
* #parameter
*/
protected boolean useJava7;
... ...
if (useJava7) {
arguments.add("--use_java7");
}
... ...
You can use the following plugin configuration in pom.xml to enable Java7 support:
</build>
<plugins>
... ...
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
<configuration>
<useJava7>true</useJava7>
</configuration>
</plugin>
</plugins>
</build>

Issus with building the java project using maven2

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>

Categories