This week's book giveaway is in the Go forum.
We're giving away four copies of Head First Go and have Jay McGavren on-line!
See this thread for details.
Win a copy of Head First Go this week in the Go 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Close Virtual Machine via keystroke or mouse click when any program is active?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,
Im a pretty big noob to coding, I have no coding skills, but have a little understanding how it all works. I would like to tap into all of your knowledge bases' for a few seconds, if you would kindly allow me to. If my question should be directed in another community, please let me know.
Anyways, i'll keep it short and sweet.
I want to run a Virtual machine on my workstation, for simple monitoring, and I want to be able to close that program/application/window/instance/whatever-you-want-to-call-it by clicking my 5th mouse button and/or a keystroke, like alt+space, while any other program. Is this possible? I am assuming the program would have to be active in order for the keystroke to close the program, but is it possible to incorporate the keystroke as a shortcut to a macro that activates that program and closes it?
I guess in short I want a 'boss' button that I will be able to execute on any windows instance that closes a specific program, all without displaying said program's window.
Any advice would be deeply appreciated.
I am using windows 10 on the machine that I need this code for.

Thanks in advance!
 
Marshal
Posts: 63496
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

What sort of Virtual Machine are you thinking of? I know you can turn off a JVM with ctrl‑C or (I think) ctrl‑Z at the terminal/command line, but I don't know about other VMs.
You need to be circumspect about stopping any program suddenly; if you are in the middle of doing something, e.g. writing to a file, that task may terminate partially done and you risk corrupting a resource.
 
Kyle Myers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right about the shortcut for most VMs, how about for any program? say a simple app like solitaire? data lose due to sudden disconnect is not a concern of mine, thanks for the concern though.
 
Campbell Ritchie
Marshal
Posts: 63496
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kyle Myers wrote:you are right . . . thanks . . . .

That's a pleasure
 
Saloon Keeper
Posts: 20514
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've jumbled a lot of things together. A window is a GUI construct with no direct relation to a VM. I run many VMs on computers that don't even have video displays hooked up to them a lot of the time. And as Campbell has pointed out, VMs come in a lot of flavours. A JVM is essentially an application program, but something like a VMWare VM is a complete simulated computer system, possibly running multiple applications within itself. My mail VM runs the mail transfer agent (sendmail), an IMAP server, a webmail server, and several other mail-related apps, for example.

You can kill a JVM with Ctl-C, bit that, in Unix terminology is SIGKILL, and you can guess from its name that it's going to be very rude. Ctl-Z is a DOS End-of-File character, so don't expect it to do anything unless your program is looping on data from stdin. Ctrl-D is the Unix/Linux end-of-input signal (SIGEOF), and the same applies there.

You can probably attach a hotkey or other HID event to a specific instance of a JVM or machine VM to tell it to shut down cleanly, but we'd need a LOT more information about what you're running to be able to suggest anything.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!