Error compiling Jersey library different Java version - java

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.

Related

Bad class file-wrong version error when using JAR but its maven configuration target is properly set

I have been trying to make a library work with our Android project. Currently, we are getting errors with the library during our lint check:
bad class file: .....
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
So I've checked out the library in question and checked its pom.xml, it seems to be properly configured to be compatible with Java 8:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
...
The library developer and I assume that should be enough, or are we mistaken and should we use Java 8 when generating the library JAR? Or is the problem solely with me and should I use Java 11 instead of the bundled JDK with Android Studio?

maven package with jdk 6

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

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.

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.

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