Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to unload a java class from memory?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
12.7 Unloading of Classes and Interfaces.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic