maven project build shows Compilation failure - java

I am creating a web application using spring mvc with eclipse as my IDE and every time I build my project I keep getting getting the following :- Compilation failure: Compilation failure:
[ERROR] /C:/Users/dev1/project/GeoVision/src/main/java/com/mmi/controllers/GeoJsonToShp.java diamond operator is not supported in -source 1.5
I have changed the java build path and set it to latest JRE and even then the error won't go.
Also, I am able to run the project on server?
Please suggest what is it that I have to change to successfully build my project?

You need to configure the compile level in IDE settings
Or configure the maven file (probably this rather than eclipse)

Related

How to upgrade to Java 11 without modules?

When I try to build my project with Maven 3.5.4 and Java 11.0.2, the build fails with the message:
Compilation failure: Compilation failure: [ERROR]
xx/directory/krb5/KerberosContextSource.java:[38,20] package
sun.security.krb5 is not visible [ERROR] (package sun.security.krb5
is declared in module java.security.jgss, which does not export it to
the unnamed module)
I have read from several sources that it's not necessary to modularise your project to upgrade it to Java 9+.
Why do I still run into this issue which clearly asks me to define a module-info.java? As mentioned here.
How do I get around it?

How can i resolve the error "Line 1: The type XX cannot be resolved. It is indirectly referenced from required .class files" in GWT?

I've got one Maven GWT application and it's throwing the error you can see in the title.
When i start my gwt project via eclipse everything works. The site will be loaded and "it's compiling". But after several seconds there is a failure.(Picture 1)
How can i solve it?
Restarting eclipse, erasing dependencies and add them again, erasing JRE or JDK and add them again etc.. does not work :'(
Important: This project is uploaded on a subversion server. My partner here at work can check the project out but does not receive this kind of failure.
I'm using Eclipse Mars 2 and work on a Windows 7 64-bit operating system
Hello I'm KilledByCheese his Coworker - I didn't changed anything in the POM or on the BuildPath ... but i took a loog at the Console output of my colleague:
Checking rule <generate-with class='com.google.gwt.place.rebind.PlaceHistoryMapperGenerator'/>
Tracing compile failure path for type 'x.z.y.client.SearchActivity.EditorFramework'
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] Errors in 'x/y/z/client/SearchActivity.java'
[ERROR] Line 71: Failed to resolve 'x.y.z.client.SearchActivity.EditorFramework' via deferred binding
It could be that you have an obsolete class file somewhere. Maven will not recompile classes if it thinks they are up-to-date but sometimes Maven gets confused. Try doing a Maven clean.
On the other hand, it could be that Maven is right and Eclipse got it wrong when it thinks there is no problem. In that case you could try Project -> Clean.
A third alternative is the the error is genuine, and that your colleague changed the build path in Eclipse without updating the pom.

How to import GAE java project (with maven) in Eclipse?

I'm reading this: https://cloud.google.com/java/getting-started/using-forms
and i'd like to import this project in Eclipse from 0, but i'm getting a lot of errors. (Generally any GAE projects).
What are the steps to do this?
Create new Java project, run Maven (?) and so on...
I need to use Mars 2 and have installed jdk 1.7 and 1.8.
THX.
(PS: It works using the guide. So i can run the app on cmd)
Update: errors after AndrĂ¡s Kerekes'solutions
Try to follow these steps:
git clone the whole Getting Started Java repository
run mvn eclipse:eclipse in the top level directory of the cloned repository
import the projects into Eclipse (including the one at the top level: the project is called getting-started-java, you should see it in the Project Explorer) using File > Import... > Maven > Existing Maven Projects
You may see an error dialog about Maven errors, in the Action field, click on the cell and select to option to install the m2e connector for the JDT compiler. This will install a plugin into your Eclipse to bridge M2Eclipse and the JDT, you'll need to restart Eclipse once it finishes.
You may still see Maven errors like Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (execution: default-compile, phase: compile), which is OK. You dependencies should be set for the project and there should be no compilation error.
Ensure that the project uses JDK8 as it depends on classes that are only available since Java 8 (like java.util.function.Function)
You may want to install the Cloud Tools for Eclipse plugin for additional GAE support.

Do I need to install Apache Maven on my PC first, or is it enough to install the plugin in Netbeans to run a Maven project?

I build an Apache Project in java which runs fine on my laptop, now that I try to run the same project in Netbeans on my work PC I get an error:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project aping: Command execution failed.
With a reference to:
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The Maven plugin in Netbeans was installed by default. When I tried to find out if the Apache version in the POM file was correct I tried to check the version on my PC with mvn -version I got the error:
'mvn' is not recognized as an internal or external command,
operable program or batch file.
Does this mean that Maven is not installed on my PC and should I also install Maven on my PC first in order to use the plugin, or should just installing the plugin be enough and do I have a different problem?
The error message you see is
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project aping: Command execution failed.
This is a message from the Maven executable embedded inside Netbeans (so Maven is running), saying that a specific maven plugin (here exec-maven-plugin) failed. This is most likely trying to invoke another program on your computer that is not installed so Netbeans (and hence the embedded Maven) can see it.
If you want to run maven outside Netbeans, you must download and install a copy and invoke the "mvn" binary inside.
You Have to install Maven To run Maven on your PC - http://www.avajava.com/tutorials/lessons/what-is-maven-and-how-do-i-install-it.html see how to install maven
in linux - http://www.mkyong.com/maven/how-to-install-maven-in-ubuntu/
I mistakenly assumed that the problem had something to do with Maven, the problem seems to be something in my source code unrelated to Maven. When I change some of the code the program is build succesfully

How do I get IntelliJ to recognise resource bundle when compiling?

Ok, first up I am almost completely unfamiliar with Java and Java tooling.
I am attempting to contribute a bugfix to a Jenkins plugin. Code-wise the fix is simple, my problem is in trying to compile the project and run the tests locally.
I have installed IntelliJ IDEA 15CE and started a new project, pointing it to my local clone of the plugin repo.
It has gone away and 'downloaded the internet' in terms of Maven dependencies. Mostly everything looks ok. What I want to do is to run the tests...
If I right-click at the root of the project and select 'Run All Tests' I get the error:
Error:(115, 29) java: cannot find symbol
symbol: variable Messages
location: class hudson.plugins.copyartifact.BuildSelector
The source of this error is a line:
console.println(Messages.CopyArtifact_MissingSrcArtifacts(srcDir));
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/java/hudson/plugins/copyartifact/BuildSelector.java#L115
As far as I can tell the Messages symbol should resolve to this properties file:
https://github.com/jenkinsci/copyartifact-plugin/blob/master/src/main/resources/hudson/plugins/copyartifact/Messages.properties
...which IDEA recognises as a 'Resource Bundle' in the project tree view.
But it doesn't seem to recognise it when compiling the project.
I have no idea where to start fixing this. The tests run fine if I push a commit to a pull request on GitHub and let the cloudbees.com Jenkins server run them, but I'd like to be able to test stuff locally first.
Run the maven compile command from Intelli-J Maven tool. After compiling error will vanish.
When you compile it will generate a Messages.java file in generated sources automatically.

Categories