Newb: how to combine 2 folders into 1 project?

Hello world,

I want to use IntelliJ to run the Java software I have here:

The software has 2 folders:


It appears that the Java code in samples/ depends on source/

I want to know how to create a project which allows me to run the code in samples/

I poked at it a bit using the menus in IntelliJ and quickly realized I should ask for help.

Question: How to create/configure an Intellij project which can run the code here:

Comment actions Permalink

Create a project with 2 modules, one for source, another for modules, make samples module depend on the source module.

Comment actions Permalink


I did this.

cd /tmp/

git clone
cd /tmp/ibjts/

Then I saw idea14 appear.

How to create a project?

Menu has these options:
  -New Project
  -New Project from existing sources

I picked
  -New Project from existing sources

I gave it this path:
  - /tmp/ibjts/

It asks for project name.

I gave it 'myproject'

Now I see a project and it has this path:

How to add modules to this project?

I see no 'add module' action in the menus.

This might seem like a simple question but I am used to interpreted
languages like Python, Ruby, and JavaScript which make it very easy to
reuse other peoples code.

Comment actions Permalink

I sense progress.

I added this folder as a module:


and now, the java-code there appears in idea14.

The first file is:

The first import is:
import static com.ib.controller.Formats.fmt0;

And it contains some red.

So, I import this folder as a module:

And that import is still red.

Is /tmp/ibjts/samples/ the correct folder when I added the 1st module?

I sense that I have these folder-choices for the 1st module:

Which one should I use?

Perhaps I see a clue in this file:

There, I see the declaration:
package apidemo;

Perhaps this Java-call has something to do with an idea-module?

Did I use the correct folder when I added the 2nd module?

I sense that I have these folder-choices for the 2nd module:

What is the correct folder choice when I add the 2nd module?

I chose

but I worry that is a wrong choice.

Comment actions Permalink

Attached is the correctly configured project with the dependencies between the modules.

Comment actions Permalink

I sense more progress.

Your zip file is very useful.

I will try to use it to recreate the steps I need to follow to create my own project.

I've spent 40 minutes trying but have no success yet.

I see that I am wrestling with two basic questions:

1. How to reuse code in Java?
2. How to use IntelliJ to reuse code in Java?

I now know that to share my code I need a package declaration in my

And, that declaration needs to match a folder structure.

Also I know that CLASSPATH is used to communicate locations of file.class

And I know that I can use javac to create file.class from

Today I learned that IntelliJ asks me to use a hierarchy:

A project has modules which have classes

Also I know that project is tied to a folder.

And that a module is tied to a folder.

What eludes me is the detailed thought process behind building a project from two folders of code.

I know that both folders depend on jdk7 and that folder-A depends on folder-B.

To me that seems like 3 simple facts that I can convey to IntelliJ.

IntelliJ should then give me a project which has all the dependencies connected together.

Comment actions Permalink

I used idea14 to study your project.

I see 2 modules:

Java[samples] tied to folder ibjts/samples/Java

JavaClient tied to folder    ibjts/source/JavaClient

I assume that that the first module has [samples] next to it for some reason.

Perhaps I use [samples] to identify the project?

I browsed various java files under ibjts/samples/Java.
I see no red anywhere so this project is okay.

I exited idea14.

I did these shell commands:

cd /tmp/
git clone
cd /tmp/ibjts/

Here I see 2 folders:


I know that samples depends on source and they both depend on jdk

I run this:

I create a 'project from existing sources' named samples from this folder:

I see lots of red in the java files.

I create a module from this folder:

On the left-hand-side,
Now my project looks like your project.

I still see lots of red in the java files.
Actually the java files in

seem to be okay; IntelliJ has found their dependencies.

Question: How to make the red go away from


Comment actions Permalink


I figured it out!

I see in your project where you set that the samples-module depends on the JavaClient-module.

I did this in my project:

  file - ProjectStructure - modules - samples - plus-sign - moduleDependency

All my red is ... GONE.



Please sign in to leave a comment.