Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to unload a java class from memory?  RSS feed

 
MukulJ Patil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using a batch file to call my java class file which loads a class when run. This class file runs for 24x7.

For some reason, i want to stop the processing of this class. I can't kill the batch as it's been called by a windows service, so it's running in the background (not visible).

I think there should be some JVM option to do so. I wish to prepare a second batch file which will pass some parameters to JVM. I searched for this but didn't get any. Please advise.

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answers depend on exactly what you're saying -- it's really hard to tell. "Unload a class" has a very specific Java meaning, but I think you're using it to mean something utterly different.

If you are running a free-standing background process written in Java, and you want to kill that process, then the cleanest way would be to have that background process listen for a connection on a local socket, and when it reads a String like "QUIT" on that socket, it calls System.exit . Then you can write a program to stop the first program just by connection to that socket and printing "QUIT".
 
wise owen
Ranch Hand
Posts: 2023
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!