I have the source code of a "util" maven project multiple times on my PC. In one directory I added a function to a class and called mvn clean install to make the new jar available in other projects.
In my main project I include the "util" dependency and can see in the NetBeans Project-tree->Dependencies, that the included jar file contains my changes. However, NetBeans throws an compile error that the new function cannot be found. If I open the imported file (Crtl+click import link), NetBeans opens a source file of a wrong (old) directory.
How do I fix this behavior?
Edit: I deleted the NetBeans Cache without success...
Edit2: I pulled the current version into the "old" directory and NetBeans compiles. Somehow the "jar" is ignored and for-what-reason this directory seams to be the reference...
Related
This issue started recently with upgrade of IntelliJ to 2021.1.2. I have multiple java maven modules in one of my project in IntelliJ. Some of the maven modules depends on other modules. When I want to view implementations of any api e.g. (Option+Command+B), it opens the decompiled .class files from the jar in my .m2 directory. Even though source of class is right there in my project. Earlier if I have imported source code of dependency module, then it will open java source file. If I have not imported dependency, only then it used to open decompiled class.
Any help appreciated, what to do so that IntelliJ first check existing source in project. and then open .java files from source instead of decompiled .class file from .m2 directory.
I just checked out some projects from svn to my pc, and I tried to import the projects into my workspace.
But I failed to import some of them, and eclipse didn't recognize those projects(didn't show up in the import window).
And then I turn to google and found a solution -"add .projects and .classpath file to project folder" works.
However, what make me really confusing is that I foundthe projects I successfully imported into workspace without manually adding the files for them also don't contain .projects and .classpath. Eclipse just create the files for them automatically after import, so it seems that the fail of importing projects(or recognizing projects during import) is not just simply because of the lack of .projects and .classpath.
Does anyone know what cause the difference?
How does eclipse exactly recognize a project as importable project?
*eclipse version info here
Eclipse or any other IDE doesn't required .classpath or .project files. These files will be auto created during the project import. IDE can capable to pull the artifacts from maven central repo automatically by using build descriptor file such as pom.xml or build.graddle.
The files .classpath and .project will store the paths from local machine, if we carry them to another system, the artificats and other dependencies may not be present in the same directory, so it will start complaining build errors. Thats why while committing to GIT always there is .gitignore, so that local configuration will not carry to others while contributing.
I'm trying to find more information on how eclipse handles Running a project.
I want to understand it more because I have an issue I'm currently having where apache-poi .jar files which have been included into the classpath of my project will work properly when the project is ran through eclipse, but will not be detected when going to the same projects folder and running the main jar file to start the program.
It gives me the error: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Cell (although sometimes instead of Cell, it's Sheet)
What could I consult to understand what is going on here, and possibly solve this issue?
Your NoClassDefFoundError indicates that the library was not available while running the jar.
This depends upon how you are exporting your project into the jar file.
If you're using eclipse to do so, you can:
Export->Java->Runnable Jar to create a jar that includes its dependencies
Make sure to check Package required libraries into generated JAR.
This will make all your jars (in build path including apache-poi.jar) as a part of the final jar.
It runs from eclipse because libraries are on the build path of the eclipse which makes them available in the classpath.
I have an android project setup using the maven-android plugin. This plugin adheres to maven output folders for the location of the R.java file (i.e. target/generated-sources/r).
However, when using this project in Eclipse, I can't configure aapt to rely on that folder.
Even if I manually go into the project properties and set up the folders manually, the ADT plugin goes in and resets just some of the settings (i.e. adds the /gen folder back as a source folder, and restores the output folder to /bin/classes instead of /target/classes), while leaving the maven /target/generated-sources/r folder and breaking the build of the project.
I would like to use the default Maven folder structure with the Eclipse ADT. Any ideas on how I can do this?
Thanks
Responding to the comments:
Yes, am using the m2e-android plugin.
Because ADT is still generating R.java in /gen, Eclipse is failing to compile if there still exists an R.java under target/generated-sources/r due to duplicated class definitions.
Unfortunately, the Android Connector for M2E does not support moving generated folders like the ADT gen folder to other directories. This is a restriction of the ADT, although there is a ticket to explore a way around this restriction:
https://github.com/rgladwell/m2e-android/issues/68
If you'd like to stay updated, please comment on this ticket.
This seems to be working for me:
Let the ADT keep gen as a source folder, but change the output folder for that source folder to be /target/classes.
I can build in both eclipse and using maven from the command line, and I don't get duplicate R class problems in either case. Essentially, Eclipse generates the R.java file in /gen, while maven generates it in /target/generated-sources/r, but both builds put the R.class file under /target/classes.
Note: at one point I had added /gen as an additional source directory in my pom.xml using build-helper-maven-plugin, and I had to remove that.
I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:
Jar export finished with problems. See details for additional information.
Fat Jar Export: Could not find class-path entry for 'C:Projects/this_project/src/com/company/python/'
When browsing through the generated JAR file with an archive manager, the python module is in fact inside of the JAR, but when I check the manifest, only "." is in the classpath. I can overlook this issue by manually dropping the module into the JAR file after creation, but since the main point of this project is automation, I'd rather be able to configure Eclipse to generate properly configured JAR automatically. Any ideas?
*NOTE*I obviously cannot run the program successfully when I do this, but removing the Python source folder from the classpath in "Run Configurations..." makes the error go away.
Figured it out, had to add the source folder with the Python module in it as a class folder in the Build Path project properties. Not sure if this next part is necessary or not, but since the module is not compiled, I added the folder again as "Attached Source" after adding the class folder.
Have a look at the maven-jython-compile-plugin and its demo project at http://mavenjython.sourceforge.net/ . It allows bundling jython with dependencies into a standalone jar.