Noobie needs help

I'm switching over from JCreator, and I simply cannot figure out how to compile/run files (I'm probably missing something very obvious here)
I created a project called "mywork" , selected my JDK, put no source files directory since I didn't know how that worked and now I created a new file, named it LeapYearJS.java and put my code into it. Now I can't figure out how to run or build it.
Help please?:|



Attachment(s):
Capture.PNG
2 comments
Comment actions Permalink

Hi,

This link contains step-by-step description of how to create your first project: wiki.jetbrains.net/intellij/Setting_up_a_project_in_IntelliJ_IDEA

In your current project you see your java file icon crossed, because your source file is not under content root. To create one:
1. Go to 'File' -> 'Project Structure' (or Ctrl+Alt+Shift+S)
2. Select 'Modules' in the left panel, choose your module.
3. Click 'Add Content Root' in the middle panel and add some directory.
After you added content directory, move your file there.

To run your project, you can simply go to any file which has 'public static void main()', right click in source editor window and choose "Run '<classname>.main()'" (Ctrl+Shift+F10). This will automatically create a run configuration for you (later, you can switch between different run configurations if you want).

Regarding build, if you want just to compile classes, by default they will be compiled automatically before your run. If you want to create JAR, configure build artifacts.

PS: actually, you just went off road by not creating source files directory.

0
Comment actions Permalink

Small clarification:

your source file is not under content root

In fact the source file IS under content root (which is ~/IdeaProjects/mywork). But it must be under source root (source root in its turn is under content root).

0

Please sign in to leave a comment.