• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Equivalent for "CTRL+C" for process made in Java  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am running pentaho jobs from command line in Java.
The pentaho job runs fine, and I am able to see the output of the command line inside a JTextArea which updates in real time.#

I now would like a "Stop" button, which does the equivalent of "CTRL+C" in the windows command prompt.

I was trying to use .destroy for the process inside a button, however this doesn't seem to work.
process is a public variable by the way.

Code:
 
Daniel Lawton
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have now tried implementing a shutdownhook when the 'somethingButton' is pressed. Here is what I've tried.

 
Saloon Keeper
Posts: 10245
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try process.destroyForcibly().waitFor().

Why are you catching the IOException at the beginning? I'm assuming that you only want to interact with the process if you've started it successfully.

I'm assuming this is a constructor, because you're adding an action listener to a button in this code. If it is, it's inappropriate to spawn a thread here. In fact, you shouldn't be using a thread at all, you should be using a SwingWorker.

You can use a lambda to add your action listener.
 
Rancher
Posts: 3354
33
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!