This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to debug a remote application using Eclipse IDE. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to debug a remote application using Eclipse IDE." Watch "How to debug a remote application using Eclipse IDE." New topic
Author

How to debug a remote application using Eclipse IDE.

Manu Manoharan
Greenhorn

Joined: Jan 12, 2009
Posts: 9
I am running a remote java application in my desktop.
All the client side jars are downloaded to my local cache.
Now I want to debug the application using my Eclipse IDE.
I have found that to this i need to set some VM arguments, like
Xdebug Xrunjdwp:transport=dt_socket,server=localhost,address =5000

Can anybody tell me how can I set these parameters ?

Thanks in advance.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Please read the important administrative private message I have just sent you.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Hint: until you fix your display name, I'm not going to tell you the answer.

We're not trying to be unreasonable here, but we do try and maintain a certain degree of professionalism here. Despite the moth-eaten moose head logo.


Customer surveys are for companies who didn't pay proper attention to begin with.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Find the class with the main method in, r-click, then "run as" -> "open run dialog." (Or run configurations. There is a tab for arguments, with a box for command-line arguments, and a box for VM arguments.
Manu Manoharan
Greenhorn

Joined: Jan 12, 2009
Posts: 9
@Campbell
Could you please tell me how can i debug remote application using eclipse?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
I only know how to debug an ordinary application in Eclipse. Rather than run as you use debug as. You double-click the left side of the .java file, near the line numbers, until you see a blue circle, which represents a breakpoint. Execution continues to the breakpoint, then you can use step into, step over, and step return (or, I think f5 f6 and f7) and execute it bit by bit. You can also inspect the values of any variables as you go.
Is that any help?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Thanks for fixing your display name, Manu. Here's your answer.

The Java VM has built-in debugging capabilities. If you start a JVM and supply certain parameters, the JVM will start listening on a TCP/IP port for debug commands - in other words, it starts up a special debugging server as part of the Java runtime environment. There is no standard port number that I know of, although 8000 is popular. You tell it which port to use as part of the debugger options.

Although you can use this builtin debugger with a simple command-line interface, most Java IDEs can also use it, and that includes Eclipse. What you have to do is use the Debug setup dialog to create a Remote Debugging configuration . In that configuration, one of the options you must supply is the host location and debugging port number of the JVM that you want to debug. The host may be the same machine that Eclipse is running on, or some other machine - all that's required is a clear TCP/IP connection to the debugging server in the JVM under test.

The only other restriction is that Eclipse has to have filesystem access to source code that matches the compiled classes being tested. To work properly, that mans you should have defined an Eclipse project and be able to view and edit the source files in the usual way. If the source code doesn't match the compiled classes exactly, the debugger will get confused, and if there is no source code available, Eclipse will have only limited debugging abilities for that class.

The JVM debugger is very powerful and can be activated anywhere where you can control the startup of a JVM. For applets, that's done using the Java Control Panel. For servers like Tomcat, JBoss, and so forth, there's usually some way you can pass the debugger activation/setup parameters in as part of the server startup. For stand-alone Java applications, you just provide them on the startup command line.
Manu Manoharan
Greenhorn

Joined: Jan 12, 2009
Posts: 9
To debug client side applications, set the environment value

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

(
PROCEDURE

For eg. in Windows, open System Prperties -> Advanced -> Environment variables -> System variables -> New.

Variable name : JAVA_DEBUG_ARG
Variable value : -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

)
Manu Manoharan
Greenhorn

Joined: Jan 12, 2009
Posts: 9
To debug client side applications, set the environment value

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

(
PROCEDURE

For eg. in Windows, open System Prperties -> Advanced -> Environment variables -> System variables -> New.

Variable name : JAVA_DEBUG_ARG
Variable value : -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

Variable name : JAVAWS_TRACE_NATIVE
Value : 1

)
[/quote]
 
jQuery in Action, 2nd edition
 
subject: How to debug a remote application using Eclipse IDE.
 
Similar Threads
Debugging on Remote Machine
Debugging a web appplication from Eclipse
Not able to do debug in jboss-4.2.3.GA
debug j2ee application from Eclipse
How to debug with J2MEWTK?