Finding a way to load appropriate jars in different OSs as per requirement.


 
Thread Tools Search this Thread
Top Forums Programming Finding a way to load appropriate jars in different OSs as per requirement.
# 1  
Old 08-07-2013
Finding a way to load appropriate jars in different OSs as per requirement.

Hi All,

This discussion involves getting a way to load different jars in different Operating Systems.

Case Scenario
---------------
I am working on a specific OS known as NSK. Its an unix flavour and powers the HP NSK Servers. I am running one of my middleware app ( a java application) on NSK. The requirement is to make this app off-platform. i.e. it must work in other platforms like LINUX or Windows as well.

To implement this, I introduced 1 more jar. Now I need to introduce a logic where-in the JVM must load the appropriate jar at runtime (jar1 on NSK and jar2 on any other non-NSK platform). I used the following logic to implement:

Code:
if (System.getProperty(os.name).equals("NSK"))
     load jar1
else 
     load jar2

The above code works fine until I hit one of the Security exceptions "SecurityException" in getProperty API used above. This tells that the user running the app does not have necessary permission to use getProperty(). So, the above logic goes for a toss here.

Is there any way to tackle this exception and still be able to find out OS details and load the correct jar? Or better, are there any better logic to implement the same?

Please refer the below link for more details about getProperty(..)
System (Java Platform SE 7 )

Thanks in advance

Regards,
Pabitra
# 2  
Old 08-07-2013
my java is significantly non-existent but try running a java shell call instead of using the getProperty API so you get around the permission issue ...
Code:
Process p = Runtime.getRuntime().exec("/bin/hostname");

# 3  
Old 08-08-2013
Process p = Runtime.getRuntime().exec("/bin/hostname");

I am afraid the above code snippet is not uniform across all platforms. For example /bin/hostname might work in UNIX but not in Windows.
# 4  
Old 08-08-2013
in that case, you must specify in the install documents that root or Administrator rights are required to run the installer ...
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

VPS has load 200, httpd load no activity, netstat nothing

Hello, on my hostserver i see one VPS of mine got load of 200.00 and netstat nothing (not a single blank line on netstat command) after some time, netstat started showing connections, but i see no excessive IP connections. tail -f /var/log/httpd/access_log shows no activity /var/log/messages ;... (1 Reply)
Discussion started by: postcd
1 Replies

2. UNIX for Dummies Questions & Answers

Find a file in group of jars

Hi, jar -tvf tools.jar | grep LinkInfoImpl Output: 4968 Fri Feb 22 02:34:52 EST 2008 com/sun/tools/doclets/formats/html/LinkInfoImpl.class However, i need the similar output for all jar files under /apps/lib/ directory and its subdirectories. Can you please help format my command to... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. Red Hat

Repacking a file inside a java archive with nested .jars

Hello, I need to repack a file inside several java archives (nested .jar files) with or without overwrite. I am using a manual approach with mc, but it's painfully slow progress. For example I want to refresh a file deep inside a java archive (with nested .jar files): I have a java... (0 Replies)
Discussion started by: Laurentiu
0 Replies

4. BSD

FreeBSD 8.1 and OSS: system freezing

Hey all, This is my first post and I'm a brand new unix user. Just to let ya know, my technical knowledge consists of windows and linux(Ubuntu, Fedora, Sabayon, and Arch Linux), so I'm not a complete NOOB at using unix-like OSes. Anyway, I installed FreeBSD 8.1 yesterday and everything is... (0 Replies)
Discussion started by: nathanbrownitt
0 Replies

5. UNIX for Advanced & Expert Users

Beowulfing and running dual OSs

Hi, I was thinking about beowulfing some computers... but I was wondering, is it possible to run a dual OS like Windows and BSD simultaneously and still get the same effect, as all these computers running together like one system? And of course I do mean running the same way in an OS like Windows.... (1 Reply)
Discussion started by: heliotos
1 Replies

6. Shell Programming and Scripting

Need help in wrting Load Script for a Load-Resume type of load.

hi all need your help. I am wrting a script that will load data into the table. then on another load will append the data into the existing table. Regards Ankit (1 Reply)
Discussion started by: ankitgupta
1 Replies
Login or Register to Ask a Question