intellij idea - cannot run "Tomcat" project on linux - java

When I configure Tomcat in "Run configuration" in intellij, button "Tomcat" does not become active, as a result I can't run the project. I do not have any message about some errors. I went thorought many tutorials (even the most simple), but all was unsuccessful.
Here some screens

It appears as though you are looking at the default setup. Not an actual configuration.
Click the green plus icon at the top of that list to open the 'Add New Configuration' menu, and select Tomcat>Local from there (you may need to click the 'X items more' option if it is not shown initially).
This will create a deployable config of tomcat based on the default setup you have shown here.

Related

Eclipse default when multiple ways to run exist [duplicate]

Whenever I hit Debug or Run in Eclipse, I get a dialog asking me what configuration I want to use.
How do I set a default configuration and bind a keyboard shortcut?
Maybe this article from Eclipse One Tips will help you:
How to run the last launched application
The answer lies in a preference hidden on the Run/Debug page:
Go to Window > Preferences > Run/Debug > Launching.
Select the option Always launch the previously launched application. It’s located at the bottom of the dialog.
The preference should look something like this:
Now you’re free to press
F11, Ctrl+F11 or click the Run/Debug
icons on the toolbar with confidence, knowing it’s going to run what
you expect it to run.
One question arises: How do you quickly run a class as a specific
application (eg. a JUnit test) if you can’t press F11 to
run it? You have some options available:
The fastest way is to use keyboard shortcuts. Eclipse allows you to launch classes using a keystroke, including JUnit tests, Java
applications, etc using Alt+Shift+X.
Alternatively, right-click on the class and select Run As. The submenu will show available options for launching the class.
Lastly, you could click the pulldown arrow on the run/debug icons in the toolbar and select Run As. The submenu once again shows
available options for launching the class.
Eclipse plug-ins that add new project types may contribute 'Launch Configurations' to control how Eclipse executes the application. For example, J2EE based projects need to publish content and start the application server. Contrast this with simply starting a JVM for a regular Java application.
When you select a configuration, Eclipse records this for future use. You can access these by selecting the 'Run/Run Configurations' menu item or selecting 'Run Configurations' from the little drop down menu next to the run and debug toolbar buttons. You can also add new launch configurations through the Run/Debug Configurations dialog that opens. In this dialog, you should see one or more configurations that you previously launched. Selecting one reveals all the info Eclipse uses to launch your application. One tab called 'Common' contains options for controlling the your favorites menu. Checking the box next to Run or Debug will add this launch configuration to the top of its corresponding menu.
If you only have a single configuration in your menu then Eclipse will launch it when you click the associated button. If you have more than one then Eclipse launches (sometimes) the most recently used. I say sometimes because, occasionally, one launch configuration causes another to launch, which cause the last used configuration to be the second one when you would expect it to be the first one. Usually this happens to me when I launch an application, which needs to be built and the build launches a tool. When this happens, just select the correct launch configuration from the drop down menu.
You can bind a keystroke combination to the Run and Debug commands through the 'Windows/Preferences' menu item. Then select 'General/Keys' in the tree control on the left.

Eclipse maven launch "has encoutered a problem" No selected resource

Developing a Maven project in Eclipse, when I click the launch button, the launch will often fail with the error:
'Launching project_name' has encountered a problem.
No selected resource
This is because I have not selected a Java class file in the editor before clicking the Launch button (little green play icon).
Usually, I have the maven console, or Git staging view in focus at the time I press the button, so I understand why it is happening, just not how to prevent it.
Surely the play button knows which project to select. Why should it care which view has focus when I press the button? The launch configuration refers to the project via a value like ${project_loc:project_name} in the Base directory field.
Is there a way I can tell Eclipse to just run the maven build, regardless of what focus the IDE has?
I am running Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0) on Ubuntu.
In Window > Preferences: Run/Debug > Launching choose Always launch the previously launched application as Launch Operation.
Make also sure not to use selection based variables like ${git_branch} without an argument.
To make git_branch independent of the selection, specify the resource (file or folder) from which you want to have the current branch name. For example, ${git_branch:/my_project}.

Run as cucumber feature not showing in eclipse

I am new to automation. Im facing this problem while running cucumber feature. It doesnt show run as Cucumber feature option at all
Screen shot of Run as options in eclipse
As, when you open a feature file in Eclipse and right-click, then you do not find an option 'Run As->Cucumber Feature', it appears that your Eclipse do not have the required Cucumber Eclipse Plug-in. You can install this plug-in using following steps:
Launch Eclipse and navigate to 'Help->Install New Software'.
Click on 'Add' button
Enter any name e.g. 'Cucumber' and type 'http://cucumber.github.com/cucumber-eclipse/update-site' as location.
Click on OK.
'Cucumber Eclipse Plugin' option will appear in the available software list.
Select the check box against it and click on 'Next' button.
Read the terms of license agreement and click on 'I accept the terms of the license agreement” if you agree with the license terms.
Click on 'Finish' button.
Let it install, it will take few seconds to complete.
After successful installation of this plug-in, if you open any feature file (i.e. file with .feature extension) and right-click, you should see 'Run As->Cucumber Feature' option.
Update 1
In Eclipse, go to 'Windows->Preferences->Run/Debug/Launching/Launch Configuration' and uncheck 'Cucumber Feature' checkbox if it is checked. Refer to below screen shot for more details:
If it is a maven project make sure you have included it as a dependency.
If you are running it as automation it would be a good idea to set it up as a maven project.
It's hard from your brief description, but if you are seeing the 'Run as Cucumber Feature' but it isn't doing anything, I had to open up the feature, right click on the white space in it, and then run as Cucumber Feature there. For some reason that worked for me.

Make eclipse debug my android PROJECT

I am writing an Android application using Eclipse. When I click on the project in the left tree view and then click debug, the IDE builds an APK and installs in the emulator / device as expected.
However, if I'm editing a file and forget to first click on the project before attempting to debug, the IDE thinks I want to debug that specific Java file. This is NOT what I want to do, I would like it to build and emulate / install on device as usual.
Is there any way to change this behavior in Eclipse?
In eclipse, you can set in workspace preferences / run-debug / launching to always launch the previously launched application (until you explicitly choose an other application: then it will be the last that will be launched).
This way, no matter where you press (ctrl)F11 or click the debug/run button, the launch configuration you used the last time will be called again.
You will still be able to launch different applications of course, by explicitly calling their launchers (the way you debug now).
The procedure you are using (clicking on the project and selecting Debug as => Android Application is OK, for the first debug session (resp. Run as, non debug).
If you want to debug the app again (regardless of what is selected in the left hand side navigator), you should just click on the Green Run circular icon (or rather on the small > sign on its right side if you want to select a different run configuration) or the little bug on its left (for debug).
If you click on one of the > you will select on of the 8 last run/debugged app. If you are sure that the last one is the one you want to run again, then just press one of these two icons (bug for debug, green arrow for run) instead of the arrows.
When you click on the project and select Debug as what you actually do is configure a default run configuration for this app or class that can be later tweaked through the Run/debug Configurations... to better suit your customisation needs. If you click again, eclipse will detect that it has already generated a default configuration (and will not create a new identical one). Alternately you can directly create your new Run/Debug config directly through the Run/debug Configurations... sub menu.
Since the ADT plugin shipped by Google does not include a Run as... Android Application submenu when you click a java class under an android project, the default launch configuration is the java application or the server application (static main method absent).
Update
To clarify things a bit. What you ask (running your android app whilst having the java class selected in the package explorer is possible). What happens when you press the 'small bug' icon does not depend on what is selected in any navigator.
The "default launch configuration" is poorly phrased.
Let me describe what happens in more detail. When you right-click on a java class say in the package explorer (or the project explorer for Java EE version) eclipse (the navigator) calls all contributions (plugins) having registered a handler for that event and lists possible candidates in a sub menu.
In a standard Java EE eclipse installation you will see at least the run on server option and if the class has a main static method with string array arguments, you will also have a the runs as ... java application option. In both cases, eclipse will generate for you a "launch configuration". These launch configurations (both debug and non debug) are all available in the launcher dialog boxes (accessible via the icons described above). They have a lot of different configuration options depending on their nature (for instance whether you debug on a server or a simple java app or an applet). What I termed the "default configuration" is that for each of this launch configuration categories, eclipse will leave these options empty.
So the first time, you will select the Android project and select the run as... Android application option. This will create a default configuration. In ADT's case, the default configuration will also probably select a default ADV and launch it (if it's not already launched). And on subsequent occasions, it will be enough to press the run or debug icon to redeploy your app back to your ADV and this will happen regardless of what is selected in the navigator.

Preferred way of developing web applications with m2eclipse

When developing Maven web applications I usually resort the the jetty-maven-plugin to quickly launch my application for local testing and debugging. Using the launch with m2eclipse has the drawback of not properly including all sources for debugging, even though they are downloaded by Maven ( see Source lookup does not seem to work ).
What is the preferred way to debug Maven web applications in Eclipse? I'd especially appreciate configurations which work with the gwt-maven-plugin.
My preferred way to develop web applications with m2eclipse is to... not use it. Instead, I use the approach described in Debugging with the Maven Jetty Plugin in Eclipse that I'm quoting below:
Step 1
Go to the Run/External Tools/External
Tools ..." menu item on the "Run" menu
bar. Select "Program" and click the
"New" button. On the "Main" tab, fill
in the "Location:" as the full path to
your "mvn" executable. For the
"Working Directory:" select the
workspace that matches your webapp.
For "Arguments:" add jetty:run.
Move to the "Environment" tab and
click the "New" button to add a new
variable named MAVEN_OPTS with the
value:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y
If you supply suspend=n instead of
suspend=y you can start immediately
without running the debugger and
launch the debugger at anytime you
really wish to debug.
Step 2
Then, pull up the "Run/Debug/Debug
..." menu item and select "Remote Java
Application" and click the "New"
button. Fill in the dialog by
selecting your webapp project for the
"Project:" field, and ensure you are
using the same port number as you
specified in the address= property
above.
Now all you need to do is to
Run/External Tools and select the name
of the maven tool setup you created in
step 1 to start the plugin and then
Run/Debug and select the name of the
debug setup you setup in step2.
From instructions provided by
Rolf Strijdhorst on the Maven mailing
list
Stopping Jetty
In order to stop the jetty server the
"Allow termination of remote VM"
should be checked in debug dialog in
Step 2. When you have the jetty server
running and the debugger connected you
can switch to the debug perspective.
In the debug view, right click on the
Java HotSpot(TM) Client
VM[localhost:4000] and chose
terminate. This will stop the debugger
and the jetty server.
Try to avoid writing code which needs a container of some kind to debug. Always write code that can run independently and wrap it in a very thin layer for deployment (thin layer -> few lines of code -> few bugs).
If you really must, try MockRunner to emulate the app server.
Other than that, you can manually add the sources in the project properties.

Categories

Resources