In Intellij, I have a java project that I would like to use (add it as a dependency) in multiple other java projects.
I've tried "Project Structure >> Libraries" and adding the project. This gives no errors, and even allows auto complete of classes and auto import of the packages from this library.
However, when I run the code it complains "package [...] does not exist." Is there any way to import an existing project?
Related
I'm trying to import Eclipse Project to IntelliJ while keeping them synced, because I want to use IntelliJ as an IDE but keep Eclipse project in the way it is now and if it anything, directly upload my programming assignments (as an Eclipse project). In other words, I want to edit Eclipse project with IntelliJ IDE, that's all.
After some searching, I discovered that you can do that in IntelliJ Like that:
Import project -> [Choose .project File] -> Keep project and module files in [some other directory] & Link created IntelliJ IDEA modules to Eclipse project files -> [Select project to import, "Empty Karel Project" in my case]
However, no .java files in my project whatsoever. That's where I need help. Am I missing or misinterpreting something? By the way, Eclipse Integration plugin is enabled.
Project files after importing:
IntelliJ IDEA allows you to import projects from Eclipse in two ways. If you do not need backwards compatibility, you typically instruct IntelliJ IDEA to create a new set of native project files. Otherwise, you can instruct IntelliJ IDEA to keep project files in sync so that you can work on the project from both environments.
Click Import Projectfrom the Quick Start window or select the File → Import Project ...menu item. Next, select the .classpath file or .project file to import and confirm.
And for other ways you can refer below link
https://confluence.jetbrains.com/pages/viewpage.action?pageId=59944389
I'm trying to replicate in Intellij something easily done in Eclipse.
I want to run this Main class from the mainProject (nevermind the errors due to the use of fictional names):
Now, the problem is I need to be able to import a configuration folder from another project, in order to run the Main class. This is easy in Eclipse:
But I don't know how to do this is Intellij. Ideas?
This is actually why I despise the Eclipse workspace. It lets developers cheat and use another project's source as a dependency of another project. This is a problem because this isn't how it works outside of the IDE.
What you need to do is create a jar of classes you depend on, then include that jar as a dependency of the project that depends on them. If you use dependency management and have a local repository (like nexus or artifactory) you can publish your jar to your local repository and then in your other project just include it in your pom.xml if you are using Maven or build.gradle if you are using Gradle.
If you are instead including libraries in your source folder, copy the jar to your project, then right click on the jar in IntelliJ and select "Add as Library...". You can also add a dependency through File->Project Structure->Modules->Dependencies tab. Add as Library is a shortcut to adding a library here and the dependency shows up here if you use Add as Library.
IntelliJ does let you import a module from another project, but again this is cheating because it will just confuse you down the road because it will only work from within the IDE, not running as a standalone application. (File->Project Structure->Modules->Plus (+) Sign->Import Module)
I'm using IntelliJ 2016 and I have some Maven dependencies (for ImageJ plugin development) that I added successfully, the two external libraries show up in the form of jar files . I've added them in project structure -> module -> dependencies and they show up correctly under external libraries as well, the classes show up inside them, and the dependency scope is set to compile.
One of them is being imported successfully, while the other is not.
The one that works is in a sub folder in the jar
import fiji.threshold.Auto_Local_Threshold;
the other one is right under the jar and the name is not recognized when I try:
import MultipleKymograph_;
I can not change the path or declare a package for MultipleKymograph_
The dependencies are imported using POM and should be ok. I saw similar questions and I tried invalidating Intellij cache. my project is in a package that com.mycompany.imagej. I think the key here is that the specific classes that I can't access are directly in the jars.
enter image description here
Just to cross-reference for anyone else who stumbles across this: the issue is that the class MultipleKymograph_ was in the default package. You cannot import classes from the default package in other code. The solution was to move it to its own package; it now lives in sc.fiji.multiKymograph.
I have a GWT project, which builds under Eclipse, but I am trying to migrate it to IntelliJ.
I appear to have imported it correctly, downloaded all the required libraries using maven / pom.xml, but when I try to make the project, I get the following error:
java: package com.infoshare.clearcore.shared.model does not exist
If I browse the sources, it is there, but using any of the IDE "goto" options fail.
The picture below shows the project structure, which has two modules one with the failing (auto generated) source code, and the other with the "com.infoshare.clearcore.shared.model" code. Is there some way I can tell the compile to look in both modules, or do I have to restructure the code?
How did you import the project? The best way I found to import Maven projects is simply to open the root pom.xml using File > Open, then IntelliJ will detect the project and import it automatically.
Eveything should be configured properly. in particular, the target folder should be displayed in another color, because the IDE knows it contains generated files (which is not the case in your current screenshot).
I am trying to add java code from a Maven project (called docx4java) which I checked out from svn to an existing Eclipse project (called DocumentManager). I have tried the normal way, that I thought would work, i.e.:
Right Click on eclipse project>Properties>Java Build Paths> Projects > Add (here I add the Maven project) and >Libraries (here I specify Native Library location e.g. docx4/trunk/docx4/src/) but I still can't get the 'Maven' classes to be recognised in eclipse. I get the message
import docx4j.src.main.java.org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator cannot be resolved
I have tried adding a test project that was compiled in Eclipse and that works fine, Eclipse seems to recognise it i.e. import org.me.TestProject works fine.
How can I get the code from the Maven project docx4java to work in the Eclipse compiled project DocumentManager?
You can generate eclipse poject files (which you can just import into your Workspace) using the maven eclipse plugin
Take a look at these ecplise plugins for a more direct integration of maven into eclipse
You should create a eclipse project for docx4java as #Attila has commented. Once that is done, you should have two projects on your workspace: docx4java and DocumentManager. At this point, what you are doing now (adding a project reference to the Java Build Paths) should work.
It seems that the source path is not configured correctly, this is why the compiler cannot find your "Maven classes".
docx4java.src.main.java...
Maven has a different directory structure and you have to tell Eclipse where to find your sources.
For a "vanilla" eclipse project, remove the standard eclipse build path src and add the maven source path src/main/java (or whereever you added the code), the compiler should correctly pick up your sources.
Note that you still have to add all jars mentioned in the dependencies section of the maven pom.xml file. Otherwise it won't compile, even if it finds your added java classes.
(Addendum: I would recommend to use maven in your existing project as well.)