• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

eclipse command line issue

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!!

This is a big big obstacle in my development time!!

I am trying to run my application in eclipse...and I wanna debug how shutdownhook works when I send the shutdown signal.

Right now there are two ways I am doing this -
1) Add the system.exit(0) in the code somewhere.
2) Create jar file, upload in unix..run it and do ctrl-c.

The first option is really not correct.....because I don't see all the possible exceptions...when I do ctrl-c in unix..i see all possible problems with the way i coded shutdownhook.

Now, second is time taking, because everytime i create jar and upload it and run it and ctrl-c the app.

Is there a possibility I can run my app inside eclipse ..and hit ctrl-c or something like that to trigger the shutdownhook??

Thanks alot!!

Will appreciate all ideas!!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,
Welcome to JavaRanch!

We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Please add a last name.

Thanks,
Jeanne
JDBC Forum Bartender
 
Jay Vasudeva
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there.
cool?
 
Jay Vasudeva
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now can someone plz help??
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to say "please".

Seriously, we're not out to be rude, but we'd rather not have the forums read like SMS L33TSPK. Unlike Arabic, English isn't a vowels-are-optional language. Think of it as I18N. Which, some to think of it, is a pretty L33TSPK term itself.

Anyway, what you're looking for isn't actually a "CTRL-C", it's what the program encounters when you type CTRL-C. Under unix, this is a SIGKILL and under Windows, it's what you'd get by calling TerminateProcess (or so the java.lang.Runtime JavaDocs tell me).

I'm unclear when and how you want to fire this interrupt. In Eclipse/unix, one way to do it is to use the "Run/External Tools" menu option and invoke the Unix "kill" program.

At a lower level, you could write a JNI class that invokes the kill() system function - or for windows, invokes TerminateProcess. The hard part is getting the process ID for the JVM you want to kill. And, of course, unless the app's running in a different JVM than Eclipse itself is, killing the JVM kills Eclipse as well.

Note that Sun explicitly states that ctrl-C-type interrupts may terminate the JVM without invoking the shutdown hook, however! So invoking exit() isn't such a bad idea after all.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jitesh,
Thanks for updating your display name. Note that you can be "Jay Vaswani" if you want to use your original nickname.

An alternate way to kill a process in Eclipse is to use the debug perspective. Set a debugging point where you want to kill the program. Then right click the thread and select "terminate." This is similar to ctrl-c in UNIX.
 
Jay Vasudeva
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys!!

Will look into it!

Also, if I find something useful, I'll share it with everybody!

Ciao!!
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic