Reputation: 309
I've been using Eclipse for a while and I'm having trouble understanding what's going on with my first project in IntelliJ. I've read the documentation, and searched other questions, but I still can't seem to grasp it. I think there is something wrong with my project structure. This is what my structure currently looks like;
I'm trying to run the JavaForLoop
class, but whenever I do, compilation fails because I have errors in the StringMethods
class of the strings
package. My question is why would that prevent compilation if the two classes are in separate packages? Neither class uses the other, and they both have the appropriate package
declaration statements. With a similar structure in Eclipse, this would work. Should I be using a different project structure?
Upvotes: 0
Views: 69
Reputation: 8529
Intellij uses regular javac, which will fail to compile if you have errors anywhere in the code.
Eclipse has it's own compiler, that allows to compile and even run code that has compilation errors, causing a runtime exception if any part of the code that has errors is run. This allows you to run parts of the code that work even if other pieces of code are failing.
The simple solution is to resolve your compilation errors. You can also use the eclipse compiler with Intellij, but I've never done this so I can't comment on how well it works.
Upvotes: 0
Reputation: 5850
By default IDEA adds Build Configuration which is executed before launch and includes following steps (taken from here):
check if it's your case in Edit Configuration screen and if so, remove it.
Upvotes: 1
Reputation: 18276
To use a class from a different package you must declare a import statement to the class.
In your JavaForLoop.java add the import before the class statement (and after package declaration where its the case)
//package ...
import strings.StringMethods;
//public class JavaForLoop { and the rest of the code
Upvotes: 0