Note: this is not a duplicate. This version of spark requires either jdk 1.7 or 1.8. The parent pom.xml entry is shown here:
<java.version>1.7</java.version>
As shown in the screenshot we have java 1.8 for the SDK and the language level:
And here are the modules settings:
But Intellij is just confused about that:
Error:(73, 51) java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
This is a spark project being built from maven on OS/X. Intellij Ultimate 14.1.4
Update Here is the pom.xml entry for the jdk
If you are using Maven, please watch your pom.xml file. Even if your IntelliJ Project is set to Java 8 your project will compile with the version of Java set in your pom.xml.
Add this to your pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Or directly in the maven plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<configuration>
<source>1.8</source> <!-- java version here -->
<target>1.8</target> <!-- java version here -->
</configuration>
</plugin>
Related
For project circumstances, I'm using older versions of Maven and Java, when I try to package the project, using maven ear plugin 2.7, uses plexus-utils version 1.1
The problem... It calls org.codehaus.plexus.util.xml.XmlStreamWriter, this class is not on plexus-utils version 1.1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml (default-generate-application-xml) on project PROJECT_NAME: Execution default-generate-application-xml of goal org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml failed: A required class was missing while executing org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml: org/codehaus/plexus/util/xml/XmlStreamWriter
How it the way to force ear plugin to use other version of plexus-utils who include this class?
A part of pom file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<finalName>PROJECT_NAME</finalName>
<displayName>PROJECT_NAME</displayName>
<modules>
<webModule>
<groupId>some.group</groupId>
<artifactId>some.artifact</artifactId>
<bundleFileName>PROJECT_NAME_01.war</bundleFileName>
<contextRoot>/PROJECT_NAME_01</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
Thanks
After a switch to JDK8 the MANIFEST.MF Attributes started returning null
https://bugs.openjdk.java.net/browse/JDK-8201636 suggests that this is a bug introduced by Oracle in JDK 8u151-8u172.
I use pom.xml and IntelliJ IDEA. pom.xml specifies (tags < and > removed)
<maven.compiler.target> 1.8 </maven.compiler.target>
<maven.compiler.source> 1.8 </maven.compiler.source>
IDEA settings show target bytecode version 1.8
JAVA_HOME set to JDK10
I have C:\Program Files\Java\jdk1.8.0_201 installed.
How to specify this version for the builds. Also does pom.xml trump IDEA project settings or vice versa?
Edit:
I've specified
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<!--executable>{JAVA_1_8_HOME}/bin/javac</executable-->
<executable>C:/Program Files/Java/jdk1.8.0_201/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
Intellij still defaults to JDK 1.5 and chokes on List<String> a = new ArrayList<>(); with "I don't understand <> with JDK1.5".
maven.compiler.target and source are nothing to do with it. Those are just arguments passed to javac.
If you want to specify the version of javac explicitly, you can use the Maven Compiler Plugin.
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable><!-- path-to-javac --></executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
Otherwise the javac from the Project SDK will be used (Project Structure > Project).
I am developing an eclipse plugin using tycho build ,It needs some non-osgi jar files as dependency.when I add the dependency in my pom file ,It does not take the dependency during maven build.
So, I have tried to make a osgi bundle which contains all the required dependencies by using the following Plugin.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>Osgi-bundle</Bundle-SymbolicName>
<Bundle-Name>Osgi-dependency</Bundle-Name>
<Bundle-Version>1.0.0</Bundle-Version>
<Export-Package>*</Export-Package>
<Private-Package>com.foo.bundle</Private-Package>
<Bundle-Activator>com.foo.bundle.Activator</Bundle-Activator>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
After that i have provided the dependency of this osgi bundle to the eclipse plugin .But still it does not take the dependency.
I have gone through lot of sites.But I am not able to get the solution for this maven build in continuous integration
But,When I tried creating new plugin project with existing jar and add the osgi bundle and export the plugin .Its work fine. But I am in need to maven continuous builds.
Please provide some solution to add the dependency to eclipse plugin project.
I have solved the problem by creating p2 repository and deployed it in the server.I have created a target definition file and linked it to my plugin project.
We can convert non osgi jars to p2 repository by using the following code.
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<!-- specify your depencies here -->
<!-- groupId:artifactId:version -->
<artifact>
<id>org.slf4j:slf4j-log4j12:1.7.10</id>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
'
For detailed information this site is very helpfull.
http://www.vogella.com/tutorials/EclipseTycho/article.html#convertjars
One possible option is to download jars into separate folder using maven-dependency-plugin, configure classpath in manifest for OSGi bundle and do not forget to include jars in build.
I'd like to evaluate code including lambda expression with Intellij 'Evaluate Code Fragment' feature. But then, Intellij raises an error Unable to compile for target level 1.8. Need to run IDEA on java version at least 1.8, currently running on 1.6.0_65-b14-462-11M4609
The evaluating code is very simple as below.
Set<Integer> set = new HashSet<>();
set.add(1);
set.stream().map(v->v).collect(Collectors.toSet());
My Intellij version is 14.0.3 and according to official document, version 14 supports lambda expression evaluation.
How can the feature be available?
Putting together the comments from adrian lange and Bohuslav Burghardt, either upgrade to the latest IntelliJ 14.1 which comes bundled with Java 1.8, or switch your current IntelliJ to use Java 1.8. See bug IDEA-132099.
To switch to Java 1.8:
Install Java 8
Change IntelliJ to use Java 8. See these instructions.
Even after applying above defined project specific settings on IntelliJ as well as Eclipse, it was still failing for me !
what worked for me was addition of maven plugin with source and target with 1.8 setting in POM XML:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.abc.sparkcore.JavaWordCount</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You can switch runtime version of JDK:
Start the IDE, Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter.
Start the IDE, use Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter.
Switch IDE Boot JDK dialog appears. Select the version from the drop-down or click "…" entry to specify the custom location.
Unable to compile for target level 1.8...Currently running on version 1.6
My guess is that your project is being run on a version of Java that doesn't support lambdas. Make sure you have Java 8 installed, and also make sure to change your project level to use Java 8, like so:
Notice that it explicitly mentions lambdas
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
compiling project with jdk1.5 using maven2
I am trying to build java project that is using java 5 features, so maven is understandably returning an error message:
... variable-arity methods are not supported in -source 1.3
(use -source 5 or higher to enable variable-arity methods) ...
Could somebody help me understand:
- Why maven is not compiling against only installed jdk that is 6?
- How can I configure it to compile against a different jdk ie, 5 or 6?
- Do I need to install maven enforcer plugin whose only beta is available to date?
Thanks in advance
I really wish Maven would not default to Java 1.3 compiler settings.
Here is what I put in all my POM files:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.5</target>
<source>1.5</source>
</configuration>
</plugin>
</plugins>
</build>
Please anyone tell me that there is a better way.