Newb: how to combine 2 folders into 1 project?
Hello world,
I want to use IntelliJ to run the Java software I have here:
https://github.com/danbikle/ibjts
The software has 2 folders:
samples/
source/
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:
https://github.com/danbikle/ibjts/tree/master/samples/Java
??
Please sign in to leave a comment.
Create a project with 2 modules, one for source, another for modules, make samples module depend on the source module.
ok,
I did this.
cd /tmp/
git clone https://github.com/danbikle/ibjts.git
cd /tmp/ibjts/
idea.sh
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:
/tmp/ibjts/myproject
Question:
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.
https://www.jetbrains.com/idea/help/creating-modules.html
I sense progress.
I added this folder as a module:
/tmp/ibjts/samples/
and now, the java-code there appears in idea14.
yay!
The first file is:
/tmp/ibjts/samples/Java/apidemo/AccountInfoPanel.java
The first import is:
import static com.ib.controller.Formats.fmt0;
And it contains some red.
So, I import this folder as a module:
/tmp/ibjts/source/
And that import is still red.
Question1:
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:
/tmp/ibjts/samples/
/tmp/ibjts/samples/Java/
/tmp/ibjts/samples/Java/apidemo/
Which one should I use?
Perhaps I see a clue in this file:
/tmp/ibjts/samples/Java/apidemo/AccountInfoPanel.java
There, I see the declaration:
package apidemo;
Perhaps this Java-call has something to do with an idea-module?
Question2:
Did I use the correct folder when I added the 2nd module?
I sense that I have these folder-choices for the 2nd module:
/tmp/ibjts/source/
/tmp/ibjts/source/JavaClient/
/tmp/ibjts/source/JavaClient/com/
/tmp/ibjts/source/JavaClient/com/ib/
/tmp/ibjts/source/JavaClient/com/ib/client/
/tmp/ibjts/source/JavaClient/com/ib/contracts/
/tmp/ibjts/source/JavaClient/com/ib/controller/
What is the correct folder choice when I add the 2nd module?
I chose
/tmp/ibjts/source/
but I worry that is a wrong choice.
Attached is the correctly configured project with the dependencies between the modules.
Attachment(s):
ibjts.zip
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 file.java
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 file.java
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.
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 https://github.com/danbikle/ibjts.git
cd /tmp/ibjts/
Here I see 2 folders:
samples
source
I know that samples depends on source and they both depend on jdk
I run this:
idea.sh
I create a 'project from existing sources' named samples from this folder:
/tmp/ibjts/samples/Java/
I see lots of red in the java files.
I create a module from this folder:
ibjts/source/JavaClient
On the left-hand-side,
Now my project looks like your project.
But,
I still see lots of red in the java files.
Actually the java files in
ibjts/source/JavaClient/
seem to be okay; IntelliJ has found their dependencies.
Question: How to make the red go away from
/tmp/ibjts/samples/Java/
??
See http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html . Make sure samples module has sources module in the dependencies.
ah,
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:
UI-path:
file - ProjectStructure - modules - samples - plus-sign - moduleDependency
All my red is ... GONE.
yay!
Thanks!!!