When I run a Java project within the Eclipse IDE, I assume in the background it is simply calling java.exe or javaw.exe with certain parameters, such as the classpath it's using and the actual class it's running.
Is there a way I can make Eclipse show this invocation, with all it's parameters? Ideally I'd like to be able to copy&paste it into a command window to duplicate the running of the project outside of the Eclipse IDE.
(Original Answer: February 2011)
Launch your program in debug mode in Eclipse.
You can then see the exact command in the properties of the Debug views (see this thread or this thread)
First run or debug one of the configurations.
In the Debug view in the Debug perspective, right-click the running process and select "Properties". The command line used to launch the configuration is displayed.
Bug 10820 was about "[java launching] Launch config: show cmd line before launch"... but it is closed as WONTFIX.
Update (March 2012)
bbuser reports in the comment having
had to remove -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:60019 from the command line shown in properties in the Debug view.
Otherwise I got connection errors.
Also changing javaw.exe to java.exe might be advisable
Related
I am suddenly getting an error while trying to remote debug a Wildfly (9.0.1) WAR web application using Eclipse.
Unable to install breakpoint in com.yadayada.rest.PageService$Proxy$_$$_WeldClientProxy due to missing line number attributes. Modify compiler options to generate line number attributes.
I have ensured the "Add variable attributes", "Add line number", "Add source file name" options are all checked in Eclipse properties. (Note based on several other similar StackOverflow posts, I have unchecked these, applied the changes, rebuilt the application, left eclipse, come back in, re-checked them, rebuild).
I exploded my WAR and did a javap -l on a class file (specifically the one I am trying to debug) and this showed me a a LineNumberTable and LocalVariableTable for all my methods, so I feel like the line numbers are being included.
I seem to be able to debug okay, but I am confused by the error.
My process to do the debugging:
1. I have a break point set in my code.
2. I have Wildfly started with the debug option (sh standalone.sh --debug)
3. I have a Remote Java Application defined in Eclipse and start debugging by clicking DEBUG on the debug configuration.
Some information that may be helpfulL
1. MacOS 10.14.15; Wildfly 9.0.1; Eclipse Photon 4.8.0 build 20180619-1200; Maven 3.3.3
2. To build my WAR, I am using: mvn clean package -Dmaven.test.skip=true
How did you do 'Add line number attribute' for Eclipse in MacOS? I cannot find the way to do it.
I'm migrating from Eclipse IDE (+ VSCode for coding Java servlets and HTML/CSS/JS webpages, respectively) to only Visual Studio Code for its lightweight.
I have several Java extensions installed for VSCode:
Language Support for Java(TM) by Red Hat
Tomcat for Java
Debugger for Java
Eclipse has a series of settings for hot reloading:
- Automatically publish when resources change
- Refresh using native hooks or polling
while VSCode doesn't seem to have any for me.
A few things I've try to reload my Java and web code:
Restart Tomcat server
Delete and re-adding Tomcat server
Delete and regenerate .war package (not sure if this does anything, it can run well without a .war package)
Good news...
It works automatically now. With Tomcat for Java Extension (And the rest of the Java Extension Pack):
https://marketplace.visualstudio.com/items?itemName=adashen.vscode-tomcat
Just make sure your settings are like this (search for "java.autobuild" to get those two in the first results):
Very important is, that you wont see any logs in the console on the HCR (Hot Code Replacement) like it happens in Eclipse ... but you in fact will see the replaced code behavior. Just debug over the piece of code you changed, and you will see it in fact changed in the running server.
UPDATE: I've found it works better with the 'manual'(default) setting. Just clicking once in the lightning icon. (Testing in Ubuntu 18.04 LTS)
[I say it works better because if I added lines to a Class' code with the 'auto' setting it will not add that code ... only if I change code in the existing lines. But with the manual setting I just save the file, and then click the lightning icon wait ~3 seconds myself and debug over the new code ... and everything goes well!!
... This solves my coding needs(lightweight Editor/IDE with Hot-Code-Replacement in Tomcat)]
Enjoy !
This article may be helpful, I migrate from other IDE to Vscode.
According to the article, if you install Debugger for Java, it enabled Hot code replacement(HCR) and then :
You can start a debugging session and change a Java file in your development environment, and the debugger will replace the code in the JVM running your code.
Hot code replacement for java comes to visual studio code
Install “Tomcat for java” extension in VScode.
Configure the Path of Tomcat in the above extension.
Now you should be able to run tomcat in usual build -> deploy mode. Now install DCEVM, By using “java -jar installer-light.jar”. (Select “Install DCEVM as altjvm”)
Place HotSwap Agent Jar in directory of your choice.
Now In VScode right-click the Tomcat server you have created. (The one from Step 3 ) And select “Customise JVM Options”.
In the file opened, Place “-XXaltjvm=dcevm
-javaagent:/[your_directory]/hotswap-agent-1.3.1-SNAPSHOT.jar” Now Right-click the tomcat server in VScode and select “Debug WAR package”, And select the WAR file.
If everything goes well, The WAR will be start in TOMCAT in debug mode with text “HOTSWAP AGENT” in the log.
Now your every save to your file will trigger Hot Reloading.
https://medium.com/#manoj_makkuboy/hot-reload-java-8-tomcat-server-in-vscode-ba6233d632e?
is there a way to display, in Eclipse, the full command line that is used to execute a java application?
I am using Juno.
Thanks in advance.
I'm not sure what you're asking, but if you're looking for the full command line of the current execution, I'm not aware of a place you can see that in Eclipse. If you are on Windows though, I'd recommend SysInternals (now Microsoft) Process Explorer. Below is an example of the properties of a process I started in Debug mode from Eclipse.
I know this is a frequently asked question, but i have been searching for a solution for my problem online since yesterday and have not been able to find any!
I am using Eclipse Helios with Tomcat 6.0.2, when ever I try to debug my code using the tomcat and eclipse i am getting the error Source not found, this is the case for even the code that i have wrote myself and not just all the jar files
I have the java build path set up correctly, I am also using jdk1.6.0 and have this set up correctly as well so that is not the problem, it does show the code when i am debugging if i right click on the debug console and go to Edit Source Lookup.... Because this will show the source code just for that run of the debugger, I when into Run -> Debug Configurations and in the Java Application window i set it up to work with Tomcat and in the source tab I added my project and all the jar files but this does not work either! when i debug again and go into the Edit Source Lookup... it does not show me the project and jar files that I have saved in there
Does anybody have any ideas what might be happening?
Its actually very easy.Click on "Edit Source Look Path". You ll get the next popup where you need to click "Add"--> This gives another popup where you could click on "Java Project"---> THis leads to another popup where you can select your project which you are debugging and this is done! Hope this works fine.
I have solved my problem, well in a roundabout way. In my catalina.bat file I have added the line
set JAVA_OPTS= -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=n %JAVA_OPTS%
below where the JAVA_OPTS are set, this will listen on socket 5001 for any debug requests. Then in eclipse, under Debug Configurations... i created a new Remote Java Application and set the port to 5001 so that Tomcat would pick this up. Now when i start tomcat using startup.bat, when the code hits a breakpoint it opens in eclipse and I can debug like normal
Hope this helps others that have this problem
Can you debug code in other projects?
if you don't know, create a new dummy project and try to debug it
if you still get source not found for all projects, then download a fresh copy of eclipse, link it to a fresh copy of tomcat and add your dummy project to see if this work.
Hope this helps
I'm currently writing a GWT application through Eclipse. Eclipse is used for development but I use the m2eclipse plugin and a Maven pom.xml with the GWT plugin to build & run it.
When I need to debug the app I must:
Invoke "Run As ..." on a Maven project (via m2eclipse) "war:exploded gwt:debug". This launches GWT's app server and waits for a remote debug connection on port 3408. The need to wait for the WAR to be exploded means it could be a minute for this to happen.
Invoke "Debug As..." a Remote Java Application to connect to the server.
I've already added both targets to favourites to lock them into the drop down but it's still a pain.
I'd like to launch them both in sequence from a single click rather than two discrete actions.
Is there any way in Eclipse to achieve this?
Try this plugin. http://marketplace.eclipse.org/content/escripts
You can define scripts of Eclipse actions easily. You create a script of starting the 2 debug session, then run with one click or shortcut.
EDIT:
The plugin was moved and is now called EASE.
https://eclipse.org/ease/
"Launch Groups" are part of the CDT. Officially supported, easy to install.
See https://stackoverflow.com/a/11905444/518491
Why are you launching like this? Can't you just launch it by GWT plugin? Go to Run Configurations -> Web Application (the blue circle with "g" inside) and create new Run Configuration.
In it, in Main tab, enter (or select) your project, and enter com.google.gwt.dev.DevMode in Main class.
In Arguments enter -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -port 8888 -war path_to_your_dir_with_WEB-INF_directory com.package.your.Module