Intellij not detecting runConfigurations xml - intellij-idea

I imported a simple sbt scala project in Intellij idea.
Once the project is imported, I create runConfigurations directory inside .idea directory and moved all the checked in runConfigurations inside
.idea/runConfigurations.
Still I am not able to see anu run configurations.

After you have imported the .run/****.xml file in the project folder, close the PyCharm project and reopen it.

Related

Module is not listed in IntelliJ "Run Configuration"

Setup:
I have imported the Git project into IntelliJ.
I compiled the project using "make compile"
Issue:
I tried to create a "Run Configuration". The Module is not listed in the drop-down window.
Debugging:
I compared it with a working setup wherein a project was created using "File->New Project" and wherein .iml was automatically created. I see that the problematic project does not have a .iml file. I could not make out any other differences.
Is the absence of .iml file the root-cause for the issue? If so, how to generate this .iml file? Rather than manual writing, I prefer to generate it using GUI to avoid any manual errors. Please suggest.
In Eclipse IDE, one can convert a project from one type to another. Ex: normal project to Maven project. A default project to Java project by editing .project file.

How do I rename my entire project in IntelliJ without having so many manual steps?

I have IntelliJ 2019.2
I occassionally mis-name my project during creation.
I have to quit IntelliJ, renaming the folder, opening project again and renaming package and project module manually as well.
Any way to improve this?
Please follow the discussion on the issue: Renaming a project in IntelliJ IDEA
There are project, module name, name in file system etc that can all be different and can be renamed. Rename of folder can be done in file system, project, module rename in the Project Structure settings.

how to correct an incorrectly imported project in Intellij. Getting error - Not a valid project ID

I cloned my repo and using the existing build.sbt, I imported the project in Intellij (I don't remember the setting I used when doing so). I notice that Intellij have the project a name of its own - web_3075 while the name of my project is TestProject (name := "TestProject"). Now when I try to compile the project, I get the error Not a valid project ID: web_3075. How could I solve the issue?
Could I safely delete .idea file and import the project again?
Workaround (but certainly not preferred approach). Unless I made some mistake, Intellij should fix this issue
1) I imported the project using build.sbt. I let Intellij do what it likes
2) It gives my project a name - web_5012. It creates .idea directory which has modules directory and some files. The trick is to replace web_5012 with your project name in all the files in .idea (.NAME file, modules.xml, scala_compiler.xml)and to replace web_5012.iml and web_5012-build.iml in .idea/modules with your project's iml files

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 .