Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing another application using java code  RSS feed

 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I need help. Following code I use to run or Launch another application



if the above code is to launch another application using java then how can I close/exit the same(another) application using java code once I press the exit button of my java app
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36417
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. It's not like JavaScript where the processes are related. Once you kick off a program like this from Java, it lives independently.
 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton for the quick reply Jeanne Boyarsky

I was looking for the solution on the net and I came across

what does this do then?
reference:
Please go through this
 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I read that bu did not understand too much!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36417
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That method takes a Thread as a parameter. Which means it has to be another Java thread, not a DDL.

public void addShutdownHook(Thread hook)

http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That allows you to execute Java code when the JVM is shut down - it does not help in your scenario (unless you want to call native Windows code via JNI that can close the other app).
 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That method takes a Thread as a parameter. Which means it has to be another Java thread, not a DDL.

public void addShutdownHook(Thread hook)

http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)


Hmm that means there no option then!

That allows you to execute Java code when the JVM is shut down - it does not help in your scenario (unless you want to call native Windows code via JNI that can close the other app).

This is what I was looking for.! Great Thanks again to both of you for helping me!
Cheers
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!