I am switching from Eclipse to IntelliJ, I'm trying to do something that's really simple to do in Eclipse. This is probably a simple question, but I have a project in IntelliJ with a bunch of small .java class files with main classes. These are just small practice programs I use for testing. I am trying to right click one of the java class files, then 'Run'. I'm expecting the class to run and see its output in the console - it looks like IntelliJ is instead trying to compile the entire project, including test classes.
How can I make IntelliJ just run the single class file without attempting to do a build of the entire project?
Also - In eclipse I am used to copying arguments to my main class into an input window when running a single java class. Is there a way to do this in IntelliJ.
Thanks, I know I can do this from a terminal, but for my purposes it would be helpful to quickly run small java programs from an ide.
Another option could be useful and quick for you. Just write your class with main
method you want to run, and then press a little green triangle either behind your main
method or behind your class name:
After that you will be able to choose an option e.g., Run, Debug or Run with Coverage:
In this case IDEA will just run your class without building the entire project.
You can change the Default settings based on your needs, to either automatically build after each change or manually. This can be achieved by clicking on File
-> Other Settings
-> Default Settings
. This is the popup window.
To change the run configurations, you can follow below steps.
Run
tab at the top Toobar and click on Edit Configurations
.+
icon and select Application
. This opens a new popup window where you can add all your VM arguments & Program arguments similar to Eclipse.Right click your class in the left side bar. Hit Run. But your class must have a main method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With