IntelliJ Idea Projects

It is not as convenient to run and debug a single java file in Idea as it was for a Python file in PyCharm. We probably need to bite the bullet and add the extra level of complexity of an Idea project

In a project, source code and compiled .class files are stored in separate folders. This is important for you to find source files you created and want to turn in. The src folder is a subfolder of the project folder.

It is also important if you want to copy example files from the course web site and put them into a new project:

  1. Create a folder with the name you want for your project (proj1 for example).
  2. Create a subfolder src (for instance under proj1).
  3. Copy the example source files for the project into the src folder.
  4. In the folder containing your project folder, create a new Idea Java project with the name of the project folder you just created.
  5. After several Next/Finsh mouse clicks, this will create the project - with your source files already in it.

To run your project the first time using the Idea support, in the top Run menu choose Run..., and then select the main class file. After this Idea should remember the class, and you can choose it directly in the Run menu.

Idea uses the programs javac and java, but with extra parameters to maintain its special folders. If you run javac and java from the command line with no special folder instructions, it creates the .class file in the same folder.

The Java4PythonCompanion.html page, "Lets Look at a Java Program" section goes over the basic use of javac and java for a single file. The javac command can also take multiple .java files as parameters.