score:17
Even though it is a runnable jar, you can still run it from a console -- open a terminal window, navigate to the directory containing the jar, and enter "java -jar yourJar.jar". It will run in that terminal window, and sysout and syserr output will appear there, including stack traces from uncaught exceptions. Be sure to have your debug set to true when you compile. And good luck.
Just thought of something else -- if you're on Win7, it often has permission problems with user applications writing files to specific directories. Make sure the directory to which you are writing your output file is one for which you have permissions.
In a future project, if it's big enough, you can use one of the standard logging facilities for 'debug' output; then it will be easy(ier) to redirect it to a file instead of depending on having a console. But for a smaller job like this, this should be fine.
score:2
With IntelliJ IDEA
you can create a Jar Application
runtime configuration, select the JAR
, the sources, the JRE
to run the Jar
with and start debugging. Here is the documentation.
score:67
You can activate JVM's debugging capability when starting up the java
command with a special option:
java -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y -jar path/to/some/war/or/jar.jar
Starting up jar.jar
like that on the command line will:
- put this JVM instance in the role of a server (
server=y
) listening on port 8000 (address=8000
) - write
Listening for transport dt_socket at address: 8000
tostdout
and - then pause the application (
suspend=y
) until some debugger connects. The debugger acts as the client in this scenario.
Common options for selecting a debugger are:
- Eclipse Debugger: Under Run -> Debug Configurations... -> select Remote Java Application -> click the New launch configuration button. Provide an arbitrary Name for this debug configuration, Connection Type: Standard (Socket Attach) and as Connection Properties the entries Host: localhost, Port: 8000. Apply the Changes and click Debug. At the moment the Eclipse Debugger has successfully connected to the JVM,
jar.jar
should begin executing. - jdb command-line tool: Start it up with
jdb -connect com.sun.jdi.SocketAttach:port=8000
score:122
http://www.eclipsezone.com/eclipse/forums/t53459.html
Basically run it with:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044
The application, at launch, will wait until you connect from another source.
so the CLI command will be:
java -jar yourJarFileName.jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044
Source: stackoverflow.com
Related Query
- how can I debug a jar at runtime?
- How can we debug a file which is inside Jar file
- How can we know if class of jar version or the local copy is being called at runtime
- How can I add JAR files to the web-inf/lib folder in Eclipse?
- How to make javac find JAR files? (Eclipse can see them)
- How can I debug doInBackground code of an AsyncTask
- How can I debug a Doclet in Eclipse?
- How can I develop and debug Chef cookbooks and recipes in an IDE (like Eclipse)?
- How do I get maven managed dependencies copied into war\web-inf\lib so I can run my GWT 2.0 app in debug mode within Eclipse?
- How can I debug this NullPointer exception?
- How can I link source to a jar package in eclipse?
- How can I build a jar for a previous Java version?
- How can I visualize jar (not plugin) dependencies?
- How can I display a byte array as a String in java's debug detail formatter?
- How can I make Tycho load platform specific fragment into the test runtime for any OS?
- How can I use Eclipse to debug tests driven by sbt?
- How can I debug two projects in eclipse at the same time?
- How can I check on debug symbol status with Eclipse?
- How can I launch more than one debug session in Eclipse from a single click?
- How can I remote debug my rcp application?
- How can I add the external jar to the eclipse rcp application?
- How can i use a breakpoint in Eclipse in runtime android code?
- How do you make Eclipse recognize Java EE jar files so Servlets can compile?
- How can I tell Flash Builder to debug a SWF in a new browser window?
- How can I browse the source code in a jar file containing source code in Eclipse?
- Maven/eclipse, How can eclipse honor maven runtime scope?
- Eclipse: How can I attach JavaDoc to multiple JAR files?
- How can I see the classes on the java classpath at runtime in a non-maven project?
- How can I package a resource file into a runnable jar
- How can I debug after certain processing is done-Java
More Query from same tag
- Debugging application gives me a red line
- How to get the path of maven settings.xml programmatically
- Libgdx FileHandle list() method doesn't work in jar file
- Android app displaying a gif
- Eclipse remote debugging, cannot see properties of object
- Adding JDBC dependency causes all artifacts to go missing
- .java not using the 2- or 3-argument View constructors; XML attributes will not work
- Create eclipse project from svn when folder name in SVN is src/java/com
- Unable to use dependency from gradle
- Upgraded Eclipse. Every app force closes
- Maven is not automatically building default folder path in eclipse
- Insert any code in the method
- 'HttpRequest.h' file not found in Android, works in iOS (Cocos2dx)
- FATAL EXPECTION : main
- How To Import Eclipse Java Jar File To VSC?
- eclipse not generate annotation process class but m2e-apt works fine
- Make Eclipse RCP package from other bundle available in JavaScript
- Error checking in Eclipse for a single file
- Unjar dependencies in a JAR with prefix
- How to capture all Network traffics(http\https) of a Web Application using Java in Eclipse IDE?
- Scanner, eclipse debugging
- Adding RatingBar to ListAdapter using Simple Adapter not working Correctly
- how to add curvy tab in eclipse 4 RCP app
- where is the class org.eclipse.ui.PlatformUI located?
- Calculator error with switch Error message java eclipse
- Spring Boot in Eclipse - no .war created
- Eclipse IDE installation fails because it can't the find mars repository
- Switching from support-lib-v7-appcompat to actionbarsherlock lib in existing project
- Unable to export non-jar files when web project is exported as a war file from Eclipse
- Symbol could not be resolved eclipse CDT