E.g. I have one main class that's only calls another class method. That other class has no main method but the executed code. How can I do that in intellij? I can do it using notepad, but in intellij its compile the entire directory where my tasks are, but I just want to run that two specific classes on that are in the task folder I am working? How to make intellij run just those two classes only, not the whole directory or any other main class close by. Does someone can explain me how intellij handle that ? Just to say it again, I have a folder with dozens of classes and if I want to run any specific two related classes using notepad++ its run perfect without going out the folder where my classes are and try to run a different class from next folder. Everytime I try it intellij is compiling the hole directory and folders . How to setup intellij for just run the classes that I want but not the hole project? Thanks.
Running encapsuletd class in intellij how to do it?
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Anonymous #10428383
4 April 2019, 02:51
never mind I got it. Everything is running fine on my intellij . There was some classes with errors on my work space. I fixed them. i just forgot the rules, no error left behind on intellij. thanks Andrew :)
+2
Andrew
4 April 2019, 14:15
Oh, yeah I understand now. You got it, all files in all IntelliJ have to be able to compile, even if you are just running one class. Here is the "solution" if you want it.
0
Anonymous #10428383
4 April 2019, 00:19
Thanks for your answer, but i think you do not got it yet. i have done all that about run command , but my problem is : i have one main class that "uses the method of an exterior class (another java class)" e.g. "solution.java" uses method calcMean() from "Arithmetic.java" in this case i am adding another class to the same folder where solution.java is. this way i keep my code out of method main(). but my problem is : intellij is returning error compiling from a totally different class from another folder that is not used in the code. but i tried it on notepad++ in a folder with dozen class and it works perfect. my main() class called the method calcMean() from another class and displayed the results. so, my questions is : how do i make intellij do it? thank you for your supports :)
0
Andrew
3 April 2019, 18:28
If I understand your question correctly, in order to just run one main method in IntelliJ, navigate to the "main" method you want to run (so you are looking at the class you want to run main from). Then you can either select Run > Run, or there should be a play button to the left of the code on the same line as the "main" method.
0