how to export intellij project - intellij-idea

I simply want to export my java intellij project from one pc to another, no need for git because I only want to test something on the other pc because it has more memory.
Surprisingly no information on this is available, there is information on how to export a project to a jar file, but I cannot import from this jar file. On their website : https://www.jetbrains.com/help/idea/2016.3/import-existing-sources-project-name-and-location.html they don't give any clear instructions on how to do this simple operation? how is this done?

Till version 2016.3.4 IntelliJ doesn't provide such facility.
Best way to do so would be to copy the whole directory containing your project or module. Doing this would retain all your project related settings.

With the latest version of IntelliJ IDEA, all you need to do is unzip the project in the new computer and then select Open in the IntelliJ IDEA new project wizard. Do not use the option to import the project from the zip file, as that doesn't work.

Take all directories of your project and copy them into the other computer. Launch IntelliJ and open the folder of your main directory project, that is all it needs to work (*.iml files do all stuff for you). If you don't know what directory is the main, you can close the project in your other IDE and see what paths it is catching. For example in my case:

Related

Command line generation of IntelliJ IDEA project files?

I prefer having one IDEA project per task I'm working on. If it's a Gradle project, I can run gradlew idea to generate the project files then rename them to be indicative of the task I'm working on (so that when re-opening from IDEA a project, it's obvious what the task is and IDEA is able to list several tasks for the same Gradle project). This works well enough if it's a Gradle project, but if it's not, I'm left with using the IDEA GUI to open the project by pointing to the working directory. Is there a command-line way to generate the IDEA project files so I can rename them prior to using the GUI? Being able to do this would also obviate the need for using gradlew idea for this purpose.
Using the GUI, create the project by pointing it to the build.gradle file or project root directory. Once the project is created:
click the File menu
click the Project Structure menu item
change the Project name text value

IntelliJ IDEA directory-based format and .iml file(s)

We started a directory-based project in IntelliJ IDEA (currently using version 2016.3 build 163.7743.44). Everything is fine, the .iml file is inside .idea/modules and we can easily share/update it.
The issue is that, sometimes, when someone clones the project and start using it the IDE doesn't care about that file (or project structure) and puts an .iml outside the project's root. It's an intermittent/random issue and I'm not able to reproduce it step by step.
We opted for deleting the .idea directory from Git and keep the configurations/settings in a JAR file.
Is there any way to tell the IDE to use one approach or the other? It's not a big deal, but I would like to know what's the reason behind that behavior.
The reason for that behavior may be that people don't use the "Open" action to open the project but use the "Import project from existing sources" action instead. The latter action does not use the existing .idea directory, but instead recreates the project structure from scratch. You should teach your colleagues not to use that action.
Note that storing the settings in a .jar file is not a replacement for sharing the project structure, because shared settings do not include project-specific items such as libraries and run configurations.

Why is my library not being recognized after importing my project?

I'm using the JDBC library in my IntelliJ project (mysql-connector-java-5.1.40-bin.jar)
I put it into a folder named lib and used right click > Add as Library to add it as a library. It worked fine.
Later, I zipped the project and moved it to another computer. After unzipping it and importing it in IntelliJ, it gave me the error SQLException: No suitable driver found for jdbc:mysql, which means that it couldn't find the library.
I looked through the file explorer in IntelliJ and it showed both the jar and XML file, and the XML file was pointing to the right location (jar://$PROJECT_DIR$/lib/mysql-connector-java-5.1.40-bin.jar).
I added the jar file as a library again and now it works. But how can I make it work without having to readd it each time?
Use Gradle (or Maven) for building and dependency management. IDEA should import a Gradle (or Maven) project just fine.
The problem was that I was overwriting the IntelliJ Module Library (.iml) file.
When you import a project to the same folder, IntelliJ asks you whether you want to overwrite or reuse the IML file. Since Overwrite was the default option, I selected it, but that caused it to forget what libraries it was using.
By choosing Reuse instead, it works perfectly.

Adding Jar files to IntellijIdea classpath

I have created a new Intellij project. But I can't use the third party jars in my project. I have the jars in a directory structure as follows:
repository/commons-logging/commons-logging-1.0.4.jar
repository/commons-lang/commons-lang-2.1.jar
etc.
I want to add them just by pointing to the repository directory, but couldn't find any ways to add them.
But when I am using classes or API from that jars, the editor can't resolve the classes.
I have tried from Project Structure but can't configure it.
Go to File-> Project Structure-> Libraries and click green "+" to add the directory folder that has the JARs to CLASSPATH. Everything in that folder will be added to CLASSPATH.
Update:
It's 2018. It's a better idea to use a dependency manager like Maven and externalize your dependencies. Don't add JAR files to your project in a /lib folder anymore.
If, as I just encountered, you happen to have a jar file listed in the Project Structures->Libraries that is not in your classpath, the correct answer can be found by following the link given by #CrazyCoder above: Look here http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html
This says that to add the jar file as a module dependency within the Project Structure dialog:
Open Project Structure
Select Modules, then click on the module for which you want the dependency
Choose the Dependencies tab
Click the '+' at the bottom of the page and choose the appropriate way to connect to the library file. If the jar file is already listed in Libraries, then select 'Library'.
On the Mac version I was getting the error when trying to run JSON-Clojure.json.clj, which is the script to export a database table to JSON. To get it to work I had to download the latest Clojure JAR from http://clojure.org/ and then right-click on PHPStorm app in the Finder and "Show Package Contents". Then go to Contents in there. Then open the lib folder, and see a bunch of .jar files. Copy the clojure-1.8.0.jar file from the unzipped archive I downloaded from clojure.org into the aforementioned lib folder inside the PHPStorm.app/Contents/lib. Restart the app. Now it freaking works.
EDIT: You also have to put the JSR-223 script engine into PHPStorm.app/Contents/lib. It can be built from https://github.com/ato/clojure-jsr223 or downloaded from https://www.dropbox.com/s/jg7s0c41t5ceu7o/clojure-jsr223-1.5.1.jar?dl=0 .

How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin?

In our project we are using jaxb2-maven-plugin to generate Java source code from XML Schema, which causes that our Maven module requires additional source code directory (in our case target/generated/main/java). Up to date I've been using Eclipse and maven-eclipse-plugin to import all the projects into Eclipse workspace. The plugin is (somehow) able to add the directory with generated source code automatically to Eclipse' .classpath file.
Recently I try to switch to (play with?) IntelliJ IDEA 9 (so I am a newbie in this environment) and I've noticed that additional source directory is not added during IDEA's importing process...
Is there any way I can configure IDEA/Maven to make importing directory with generated source code automatically?
The convention with Maven is to generate code in target/generated-sources/<tool>, for example target/generated-sources/jaxb2
Follow this convention and IDEA will add the folder as source folder (see IDEA-53198).
Generated code, using jaxb2-maven-plugin, was missing for me in Intellij 2017.1 whereas Eclipse Neon created it.
Fixed it from context menu of module by selecting 'Maven -> Generate Sources and Update Folders'.
Try with maven-jaxb2-plugin. If it does not work then it's IDEA problem.
In Maven you can add new source roots per configuration. Maven plugins can do this programmatically. This is for sure the case with maven-jaxb2-plugin. Then, if IDEA does not recognize it, then it's a problem on that side.
You can use the Maven Build Helper Plugin. It is located at http://www.mojohaus.org/build-helper-maven-plugin/
It allows to configure additional source roots. And the maven integration of IntelliJ will add the new source root. We are using this feature in quite a few builds and it works just fine. Tested with vers. 13 of IntelliJ IDEA.