LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-13-2007, 12:18 AM   #1
devn
Member
 
Registered: Mar 2007
Location: Bangladesh
Distribution: Suse, Solaris
Posts: 40

Rep: Reputation: 15
Question How do I get platform specific info in Java


Hi,
I am coding in Java the skeletal structure of a program that uses the p2p system. A centralized server communicates with the clients and when clients want to transfer some file or sth, the server initializes the p2p between the clients.

The communication protocol I am working on is pretty simple for start. The main concern for me is to start the server and the clients on boot. I can achieve this using init scripts at rc* in *IX. But about windows, I am going to use the "reg" system command to add my program at the registry. But looks like its hell of a registry job to do and am not so good at win32 registry hack.

My query, "Is there a generic way I can make my application start at boot time using any java classes?"
And I want to know detail about the platform my application is currently running on. How do I fetch that?

Any suggestion is welcome.

 
Old 10-13-2007, 03:24 AM   #2
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Java was created to hide platform specific details from developers. If you need hardware access, use JNI (java native interface) to call OS specific libraries. However, this way your program will need to determine it's working environment and make calls accordingly. Btw, check Java API Runtime class.

How to start a program at boot time is not a java api problem. It should be users prerogative, so each user should modify their environment accordingly.
 
Old 10-13-2007, 11:15 AM   #3
devn
Member
 
Registered: Mar 2007
Location: Bangladesh
Distribution: Suse, Solaris
Posts: 40

Original Poster
Rep: Reputation: 15
Question

Quote:
However, this way your program will need to determine it's working environment and make calls accordingly. Btw, check Java API Runtime class.
Thanks for the quick reply. Anyway, my main query is actually how to get OS properties, such as the hostname, current user name, platform type (output of uname -a for *IX). Since the problem is platform (only OS, not hardware), I want to get what OS the user is running.

I know System.getProperty is one of the methods, but its doesn't have a rich set of parameters to get system info. Is there any other way?

Plz help...
 
Old 10-14-2007, 07:10 AM   #4
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Code:
Key  	                        Description of Associated Value

java.version 	                Java Runtime Environment version
java.vendor 	                Java Runtime Environment vendor
java.vendor.url 	        Java vendor URL
java.home 	                Java installation directory
java.vm.specification.version 	Java Virtual Machine specification version
java.vm.specification.vendor 	Java Virtual Machine specification vendor
java.vm.specification.name 	Java Virtual Machine specification name
java.vm.version 	        Java Virtual Machine implementation version
java.vm.vendor 	                Java Virtual Machine implementation vendor
java.vm.name 	                Java Virtual Machine implementation name
java.specification.version 	Java Runtime Environment specification version
java.specification.vendor 	Java Runtime Environment specification vendor
java.specification.name 	Java Runtime Environment specification name
java.class.version 	        Java class format version number
java.class.path 	        Java class path
java.library.path 	        List of paths to search when loading libraries
java.io.tmpdir 	                Default temp file path
java.compiler 	                Name of JIT compiler to use
java.ext.dirs 	                Path of extension directory or directories
os.name 	                Operating system name
os.arch 	                Operating system architecture
os.version 	                Operating system version
file.separator 	                File separator ("/" on UNIX)
path.separator 	                Path separator (":" on UNIX)
line.separator 	                Line separator ("\n" on UNIX)
user.name 	                User's account name
user.home 	                User's home directory
user.dir 	                User's current working directory
What are you missing?
 
Old 10-15-2007, 12:44 AM   #5
devn
Member
 
Registered: Mar 2007
Location: Bangladesh
Distribution: Suse, Solaris
Posts: 40

Original Poster
Rep: Reputation: 15
Thumbs up

Dear Alien_Hominid,
Thanks for the keys. I find it very useful. Thats all I needed.

Actually I will be using win32 registry (by using a system call to reg once I know its win32) to add my application to the Windows startup. For UNIX (actually on Solaris mainly), I will be able to put it up as service in the SMF. I will now be able to do all that in no time.
Thanks again.
devN
 
Old 10-15-2007, 12:51 AM   #6
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
np. I just pasted from manual.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get info about a specific process hfawzy Programming 4 01-31-2007 01:11 PM
How do I get PID info about a specific script? Stepaj47 Linux - Newbie 2 11-14-2005 04:31 PM
Replaciing java platform by Sun's Java platform machan Linux - Newbie 1 11-11-2005 01:55 AM
pass locale info to a specific application? Peff Linux - Software 2 06-24-2005 04:40 AM
request for VL specific security info aus9 VectorLinux 1 12-11-2003 05:43 PM


All times are GMT -5. The time now is 05:02 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration