|"Unknown Source" while using Java to debug and "Stop at main" not working [message #989737]
||Fri, 07 December 2012 08:21
| V User
Registered: December 2012
I am experienced programmer/debugger but come from a C++, Visual Studio & windbg debugging background. |
This is the first time I am using Eclipse & the first I am debugging a java program with Eclipse.
This is the scenario.
I have a jar file which is my application (c:\work\myapp\myapp.jar)
I have the sources in a separate directory (c:\work\src\)
myapp.jar is run using javaw.exe.
When I run myapp.jar from the command line, this is how I run it
javaw.exe -jar myapp.jar
I don't have a build environment. myapp.jar contains META-INF about the main class inside the jar.
c:\work\src has the source files in the same directory structure in which they were built - i.e. for com.xyz.A, the source file would be c:\work\src\com\xyz\A.java
With great difficulty I have managed to get the jar file to run under the debugger in Eclipse.
This is how I did it.
- I created a debug configuration under Java Application called myapp
These are the settings
1) Main Tab
Project - Empty
Main Class - c:\work\myapp\myapp.jar
Stop in Main is checked
VM arguments "-jar"
4) Classpath - nothing
5) Source - c:\work\src
6) Environment - Empty
When I click on "Debug" from the "Run" menu - my Application launches but it does not break in main - I assumed the "stop at main" option would make it break as soon as main is started - but it didn't so so.
In a window called "Debug", I can see
myapp [Java Application]
"c:\work\myapp\myapp.jar" at localhost:64859
Thread [AWT-Shutdown] (Running)
Daemon Thread [AWT-Windows] (Running)
Thread [AWT-EventQueue-0] (Running)
Thread [Thread-3] (Running)
Thread [DestroyJavaVM] (Running)
Thread [Thread-4] (Running)
C:\Program Files (x86)\java\jre6\bin\javaw.exe
When I right click on the jar line above & chose properties I see the following command line
"C:\Program Files (x86)\java\jre6\bin\javaw.exe" -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:64859 -jar -Dfile.encoding=Cp1252 "\"c:\work\myapp\myapp.jar\""
How do I get my application to stop at main while debugging.
Earlier before I got everything upto this stage, the app threw an exception because of some file it couldn't find - I fixed this by copying the file. When the exception happened, at the call stack - I saw (unknown source) in the line corresponding to my main. So I suspect that even after get my debugger to break in main, I will still not be able connect the debugger to the sources.
Any idea where I am going wrong?