intelli j output not generated by build - java

I am trying to build a JDBC driver for neo4j, but no out directory has been created on build.
I downloaded IntelliJ and the current JDK and cloned the repo. I can see the source and run tests: all of which succeed. I assume that step was successful.
Initially on build I got warnings saying to try running build with -xlint:unchecked so I added that under compiler settings additional command line parameters and rebuild. So far so good, I now get warning messages.
The warnings are unchecked method invocations, unchecked generic array creation, unchecked conversions, or deprecated function calls. Seems like pedantic issues that shouldn't actually be problems since the tests pass. (unless in this context deprecated means actually incompatible with current compiler?)
I checked the project structure and the compiler output is set to project_home/out, but that has not been created by the builds...
What am I missing?

Usually a module specific output path is used in IntelliJ. This can be found under
Project Settings -> Modules -> Path
and there is a radio button for "Use module compile output path".
As #ochi already mentioned: usually the output folder for maven projects is target.

Related

error in my code that code is not running [duplicate]

What are the possible causes of a "java.lang.Error: Unresolved compilation problem"?
Additional information:
I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process.
I would expect to see LinkageErrors or ClassNotFound errors if interfaces changed. The above error hints at some lower level problem.
A clean rebuild and redeployment fixed the problem. Could this error indicate a corrupted JAR?
(rewritten 2015-07-28)
Summary: Eclipse had compiled some or all of the classes, and its compiler is more tolerant of errors.
Long explanation:
The default behavior of Eclipse when compiling code with errors in it, is to generate byte code throwing the exception you see, allowing the program to be run. This is possible as Eclipse uses its own built-in compiler, instead of javac from the JDK which Apache Maven uses, and which fails the compilation completely for errors. If you use Eclipse on a Maven project which you are also working with using the command line mvn command, this may happen.
The cure is to fix the errors and recompile, before running again.
The setting is marked with a red box in this screendump:
try to clean the eclipse project
you just try to clean maven by command
mvn clean
and after that following command
mvn eclipse:clean eclipse:eclipse
and rebuild your project....
Your compiled classes may need to be recompiled from the source with the new jars.
Try running "mvn clean" and then rebuild
The major part is correctly answered by Thorbjørn Ravn Andersen.
This answer tries to shed light on the remaining question: how could the class file with errors end up in the jar?
Each build (Maven & javac or Eclipse) signals in its specific way when it hits a compile error, and will refuse to create a Jar file from it (or at least prominently alert you). The most likely cause for silently getting class files with errors into a jar is by concurrent operation of Maven and Eclipse.
If you have Eclipse open while running a mvn build, you should disable Project > Build Automatically until mvn completes.
EDIT:
Let's try to split the riddle into three parts:
(1) What is the meaning of "java.lang.Error: Unresolved compilation
problem"
This has been explained by Thorbjørn Ravn Andersen. There is no doubt that Eclipse found an error at compile time.
(2) How can an eclipse-compiled class file end up in jar file created
by maven (assuming maven is not configured to used ecj for
compilation)?
This could happen either by invoking Maven with no or incomplete cleaning. Or, an automatic Eclipse build could react to changes in the filesystem (done by Maven) and re-compile a class, before Maven proceeds to collect class files into the jar (this is what I meant by "concurrent operation" in my original answer).
(3) How come there is a compile error, but mvn clean succeeds?
Again several possibilities: (a) compilers don't agree whether or not the source code is legal, or (b) Eclipse compiles with broken settings like incomplete classpath, wrong Java compliance etc. Either way a sequence of refresh and clean build in Eclipse should surface the problem.
I had this error when I used a launch configuration that had an invalid classpath. In my case, I had a project that initially used Maven and thus a launch configuration had a Maven classpath element in it. I had later changed the project to use Gradle and removed the Maven classpath from the project's classpath, but the launch configuration still used it. I got this error trying to run it. Cleaning and rebuilding the project did not resolve this error. Instead, edit the launch configuration, remove the project classpath element, then add the project back to the User Entries in the classpath.
I got this error multiple times and struggled to work out. Finally, I removed the run configuration and re-added the default entries. It worked beautifully.
Just try to include package name in eclipse in case if you forgot it
Import all packages before using it, EX: import java.util.Scanner before using Scanner class.
These improvements might work and it will not give Java: Unresolved compilation problem anymore.
Also make sure to check compiler compliance level and selected jdk version is same
As a weird case, I encountered such an exception where the exception message (unresolved compilation bla bla) was hardcoded inside of generated class' itself. Decompiling the class revealed this.
I had the same issue using the visual studio Code. The root cause was backup java file was left in the same directory.
Removed the backup java file
When the build failed, selected the Fix it, it cleaned up the cache and restarted the workSpace.

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.

Ho do I generate eclipse project without compiling or ignoring compilation errors using SBT and play framework?

Recently our project's dependencies artifact name has been changed so as the package names and some classes' names. Now we need to update our project dependencies for our next release. Problem is when invoking eclipse from play console it just doesn't do that if there's any compilation errors which of course is expected. I just want to update the eclipse project settings and fix compilation problems later.
It should generate the projects even if there are compilation problems. You might want to check your sbteclipse version.
There might be a chance that it will not even compile when generating the eclipse files. This could theoretically be triggered by a related sbt issue: compile is executed for discoveredSbtPlugins when the project is not a plugin
So if you are not creating an sbt plugin and have an updated sbteclipse version and still have problems, you could try setting: discoveredSbtPlugins := PluginDiscovery.emptyDiscoveredNames.
I would strongly advise you to first see if the compilation problems are causing the projects not to be created. In the past I have often created projects when I had compiler errors. It will for example not create the project if you have an unresolved dependency.

Which class is Maven calling?

I am looking at an internal Maven application I am building in IntelliJ (same results in Eclipse), and everything looks perfectly clean.
I run clean and compile from IntelliJ (using IntelliJ build or using IntelliJ Maven support) and everything compiles fine.
However when I run the build from the command line (mvn clean compile) I am getting build exceptions (see below).
The command line seems to be looking for a genericized parameter (to the "with" method), which we are indeed passing in correctly. However it is complaining as if we were passing in a non-generic parameter.
Obviously mvn on the command line is using a different version of the "with" method than IntelliJ.
Is there any way to ask Maven to tell me which version of a class it is using, in terms of group, artifact and version of the containing jar?
Here is the precise error
[ERROR] \dev\try-deploy-1\src\main\java\com\victor\webui\WebUserInterface.java:[147,47]
attribute(java.lang.String,org.hamcrest.Matcher<java.lang.String>) in
org.openqa.selenium.lift.Matchers cannot be applied to
(java.lang.String,org.hamcrest.Matcher<java.lang.Object>)
Is it possible that you have another version of the class somewhere? try adding a comment on a new line in the file so the line number changes, and re-run the maven compile to see if it still gives the same line number for the error.
In Eclipse, sorry I know you are using IntelliJ, the maven build usually does an offline build that's why it's so fast. There is a way to force it to do a clean with all the jars though and I use that when I get in a bind. It is the Update Project command and it has a box to force the update of snapshots and releases. Maybe Intellij has something like that? Also I'd verify the version you are using on command line is the same as the one IntelliJ is using (I have a few versions installed). You can check Settings in IntelliJ and
mvn -v
on the command line. Finally I'd make sure the settings.xml files you are using for command line and IntelliJ are the same file.
Good luck.

Netbeans & Maven: different compilation behavior

I am using Netbeans and Maven projects.
In some case Netbeans show me compilation failures (red ballon) BUT Maven compile everything without any problem!
What can be the reason of this difference.
I already checked that both are using the same JDK version.
One possible reason could be that you have not added the required jar in your net beans class path. But the jar is being listed in your maven pom.xml
Try doing this, do an mvn install once from your command line in your project directory, and then re-open or reload the project in your netbeans IDE (I hope you are using 6.9?).
This will install all the artifacts in your local repo.
This usually happens if you have modules in your maven project and they depend on each other.
some more details would be needed for more in-depth analysis.
In most cases a difference in compilation errors between cmdline and netbeans editor can be caused by missing source roots (read generated source roots - see the project properties Sources panel on how to setup source roots).
netbeans is embedding an old svn HEAD snapshot maven binaries so in some very rare cases there could be differences in resolving the dependency tree, but I have yet to see such case.
also the netbeans compiler doesn't pick up most of the switches defined on the compiler plugin
apart from target/source, encoding.
The netbeans editor compiler is not 100% compatible with jdk compiler and there have been cases of incompatibilities so we are back to the need to see the actual errors first..

Categories