• Post Reply Bookmark Topic Watch Topic
  • New Topic

Shutdown (spec requires : OS/Platform independent)  RSS feed

 
Ben HiLLeLi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I finally gave up "independant tinkering" and am hoping for a response or at least a refferal to one on this forum... I need to write a program that gets a trigger from a remote source and then shuts down...
Basically, there is a "server" which will send a simple signal to various clients (I'll probably just use plain old socket i/o for this). When the clients get this signal they will then start an orderly shutdown of the respective OS.
I would like to make this "somewhat" platform-independant as this is a program whose scope-of-use is rather large. The server actually gets triggered to shut-off all of the clients by a UPS Battery Low signal, most clients have at least 1 non-windows machine on-site hence the Platform issue and my choice of Java (I've scorned and avoided it for as long as possible, finally necessity has thrown Java upon me... That is - I am not going to setup a Linux, AIX, Solaris (on x86, SPARC etc.) environment just to get this small project rolling!
When I say "device-independant" I do not mean it in the strictest sense. If necessary, the user can state the OS and platform during the configuration of the clients (no need to auto-detect platform)...
My question: Is there a safe shutdown class/method in the Java lib (proprietary OR standard (free) libs!) or must I write seperate shutdown scripts for each platform (simple albeit a HUGE pain to develop and test)...
ThanX in advance
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shutting down an OS is a particularly non-Java like thing to do. The program MUST be aware of what OS that it is running on before it can do anything. However it can figure that out by looking at
System.getProperties("os.name");
After that however, you are going to need to interact with each OS differently. Probably you would need to use some JNI. However first you could try issuing some OS specific commands using
Runtime.exec("some meaningful commands");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!