How can I easily run different configurations in Eclipse? - java

I have an Java applications which I would like to run with different values of input parameters (specified in the command line). In "Run -> Run Configurations" I have created different configurations corresponding to different values of the input arguments.
I can run these configurations in the same way (throw "Run -> Run Configurations"). But in these case I have to perform to many actions (clicks) to run a particular configuration. Is there a easier (faster) way to do that? For example I expect that I can do it throw "Run -> Run as" but in the drop-dawn menu of the "Run as" I see "(Not Applicable)".

In the toolbar, the Run icon, has a small arrow pointing down. That gives you a list of recent runs with corresponding configurations. This still takes a number of clicks.
I have not been able to figure out how to (if possible) add shortcuts or keybindings to a particular run

Once you have run a particular configuration once (by going through the Run Configurations window) that configuration should show up in the list of run configuration history, so you can just select the drop down arrow and choose that configuration.
Or choose organize favourites and add your configurations. These should then show up in the drop down list.

Related

Running Projects in IntelliJ

I've got a project from my teacher, in which i should add my implementation for a certain aspect.
The Project already got a main method but still the "Run" and "Debug" buttons in the top right corner are greyed out.
I've also tried right clicking the main method and java file, but it doesnt show me run or debug.
Also tried using the "Make Project" Button (top right corner), but it doesnt let me run it either.
How can i run the project?
Help would be much appreciated cause I cant seem to find a solution...
the "run" and "debug"-button in the top run the currently selected main-method. As long as you haven't selected one, you can't run it. In the current version on the left side of the editor-pane, there should be a green arrow right next to the main-button. Run it once via clicking that arrow and from that point on you can run/debug the program using the buttons on the top-window.
In this image you can see the green arrows (version 2016.2.4).
Alternatively, you can use the following more complicated, but also more versatile option:
Directly from the run- and debug-buttons is a button that toggles a list. In the initial configuration of the project, this list contains exactly one Item: "Edit Configurations...". Use it to create a custom-target - go for Application, if your using a java-class as entry-point - and set up the configuration as you wish. Clicking the arrow mentioned earlier does basically the same with a bit of automatic configuration.
Third alternative:
Open the context-menu on the main-method. It as well contains options to run and debug the program with the marked method as entry-point. Works for the context-menu of the respective class as well.
You have to add a run configuration. Do this with clicking the grey button and then clicking at sth with configurations (i am not in front of my PC), then add there the config
Does your main method have the proper syntax for arguments? I found that in Eclipse, the program will not let you run the main method if it is not in the format of public static void main(String[] args). Also, does your code compile properly and your IDE just doesn't let you run it?

Why I have to go to run configuration in Eclipse, everytime?

I wrote two java projects which are purely independent.
When I run the first project "aa", automatically a "Run Configurations" window appeared, and I chose "cc" (cc.java) under Java Application tab.
The app run.
but when I made another java project "dd" and wrote code in its class "ff", The run button showed the output of cc.java in console.
I had to go to "Run Configurations", and select "ff" (ff.java) under Java Application tab.
Why I have to to do this everytime?
What if I have multiple classes under one project?
Is there anyway to run a project by simply clicking run button?
Regards,
BAQAR RAZA MANGRANI
Struggling programmer.
As far as I know, if you have several classes including a main method in eclipse, as soon as you run them once, they appear as shortcuts when expanding the run button(or debug). Just click on the small arrow next to the start button and select the file you want to run.

How do I stop Eclipse (STS) from creating a new runtime configuration every time I start a server

I'm using Spring Tool Suite (rejiggered eclipse) and for some reason, occasionally when I start a server (servers view pane, right click, start), instead of using the runtime configuration I've edited (specifically, with new VM args, e.g. -Xmx1234g, -Dlog4j.doAThing=true etc), it will generate a new runtime configuration (so instead of Server-Name, it will run Server-Name(1), or if that already exists Server-Name(2)) with defaults and run that instead. It's more irritating than anything, but I'd like to find out what the cause might be and fix it instead of just tolerating it running wrong.
Rather than right clicking on the server and selecting Run, try clicking Run -> Run Configurations... from the menu bar at the top of the screen and then find and run the server from there. Alternatively there is a green run button on the tool bars with a small down arrow next to it. There should probably be a launch option for the server shown there.
I have the default config called
The following worked for me:
Created config called X copied VM args from , copied User Entries JARs on the Classpath tab. Launched the config to verify it is working
Removed config . Only have X left
Now launching server from the Servers view launches my config X
Perhaps Classpath tab User Entries are not matchi

Debug and release configurations in a java netbeans project

Is it possible to have some sort of debug/release configurations that I can chose between so i can have some variables altered when compiling my project?
For example, alternate between database login variables or turn off some output debug variables.
Thanks
For Java projects in NetBeans, you can create multiple configurations. Right click the project in the Projects window, choose Set Configuration > Customize. In the top right of the new window, for Configuration, choose New.... Give the new configuration a name and click OK. Now you can set different command line switches (Arguments) and VM Options for the new configuration.
Any configuration that you create here you can then choose from the project's context menu (right click, select Set Configuration > MyConfig).
This kind of configuration is easily handled via command-line -D parameters, which should be settable in the run configurations, or via configuration files which can be selected the same way (usually cleaner, if there's a bunch of parameters).
Depending on frameworks in use there are also multiple ways to handle this.

How do I set the main Java type in Eclipse?

How do I set the main Java type in Eclipse (latest)?
I have a main client, and then a bunch of unit tests that exercise various code paths and conditions. Normally I'd like to debug or execute the unit tests depending on the feature I'm developing. However, when the boss shows up, I'd like to quickly run my main driver class without hunting and pecking for the .java file, then hitting debug.
Is there an easy way to set/change the main type? How do folks normally handle running unit tests in Eclipse?
Click on the arrow in the run/debug icon and select Organize Favorites at the bottom and set favorites for anything you don't want to fumble around for later.
For unit tests, I just run them like anything else in Eclipse. I also include a test target in my Ant scripts.
For unit tests :
You can make test suite so to bundle them by feature. This way you just need to run the test suite related to your feature.
Having several launch configuration :
Just go Run Configuration... or Debug Configuration ... from Run menu and create the configuration you want. Next time you'll want to Run them go again to that menu select it and click Run/Debug;
To gain time you can go to Keys configuration and set at shortcut to "Run..." or "Debug..." submenu.
Right click on your test folder and "Run as ... -> JUnit test"?
From Run > Run Configuration... Create a new Run Configuration for the type of java application you have and the options let you specify the main class.
And these configurations will be available in the Run As button dropdown.

Categories