Setting java and returning version


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting java and returning version
# 1  
Old 07-02-2013
Setting java and returning version

I am currently trying to write a script and I am not that great at wording it with taking in user input, it will do the following:

ask " Have you stopped instances? "
if instances are stopped, then I want it to change to the default java to 64 bits, and print the current version of java.
Afterwards I want it to return the default back to 32 bits.

Basically I want it to remove the existing symlink and recreate a new link to point to the other java version and display the info.
Code:
 
#!/bin/ksh
# -*- Mode: Bash; tab-width: 2; indent-tabs-mode: nil -*- vim:sta:et:sw=2:ts=2:syntax=sh
 
read -p " Have you stop the instances? [yn]" answer
if [ $answer = y ] 
then 
read -p " Do you want to set Java default to 64 bits? [yn]" answer
  if [ $answer = y ]
then (setServerJava -b 64)
elif
read -p " Do you want to set Java default to 32 bits? [yn]" answer
  if [ $answer = y ]
then (setServerJava -b 32) 
else 
echo "You have not stopped instances yet, cannot set Java default."
fi
 
 if [ setServerjava -b 64 ]
then
JAVA_VERSION=`java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'`
# export JAVA_VERSION
echo $JAVA_VERSION
 fi
fi

any and all help is GREATLY appreciated, thanx

Last edited by bigbenn; 07-02-2013 at 12:47 PM..
# 2  
Old 07-10-2013
Usually, it is sufficient to set the $PATH so that the desired JAVA is before competing paths. However, to set a symlink is just "ln -s source_path target_path". The source path, if relative, needs to relative to the target path dir. Removing a symbolic link is just "rm target_path".

Some versions of JAVA also have a server mode, as opposed to a client mode, where there is more exhaustive compilation in the server mode; the client mode is more restrained, optimized for quick startup.

Last edited by DGPickett; 07-10-2013 at 03:43 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. HP-UX

Setting up new version of java

Hi, I have got jre 1.5 that I have got to install in the HP.UX version 11.31. I managed to install it with this command : # swinstall -s /tmp/<jre.XXXXX.depot> It automatically gets created in /opt/java1.5/jre/bin. However, now I am not sure how to set the PATH to JAVA_HOME, and path to... (1 Reply)
Discussion started by: anaigini45
1 Replies

2. Programming

Java Runtime.getRuntime().exec not returning any value

Hi, i written class like this but it is not returning any results and infact p.waitFor() is returning value 1. This is very basic program that i am planning to run in unix. This is really killing my time and unable to find correct reason.... (6 Replies)
Discussion started by: sbjv
6 Replies

3. Shell Programming and Scripting

installed java version ?

Hi, I want to know what version of the java is installed? Please let me know the command or process to identify the installed java version in sun solaris box. Thanks in advance for all your support. (3 Replies)
Discussion started by: sridhardwh
3 Replies

4. Solaris

java (java -version)

hi my box is a global zone with no local zones and the command java -version shows as "1.5.0_26". now we got a requirement from the application team to install jdk1.5.0_24. Is it possible to install the version of java(jdk1.5.0_24) as requested by the application team or is it possible to... (2 Replies)
Discussion started by: newtoaixos
2 Replies

5. UNIX for Advanced & Expert Users

Advanced Search * View * Edit JAVA version to WORK in GLASSFISH Forum topic JAVA version

Would like to confirm the ff. I got confused actually with the version I needed to download that will work on glassfish 3.0.1 a. Debian Squeeze (HP DL360). Need to use java version6 On Debian, I did apt-get install sun-java6-jdk. So when I check it's java version "1.6.0_22" Java(TM) SE... (1 Reply)
Discussion started by: lhareigh890
1 Replies

6. Solaris

Solaris 10 Java version

I have an issue here setting up ASR with a server. In order to have the SASM service runnning/enabled, the required java version is 1.6 U18(latest). My OS came with JDK 1.5 I downloaded and installed 1.6 But when I did java -version , its still showing 1.5 I captured the below from another... (4 Replies)
Discussion started by: incredible
4 Replies

7. UNIX for Dummies Questions & Answers

malloc returning NULL if freemem high & swapmem low (MPRAS version 3.03 )

Hi All,:) In my application malloc is returning NULL even though there is sufficient amount of free memory available but the swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ? Few details: ... (4 Replies)
Discussion started by: Ritesh Kumar
4 Replies

8. Solaris

Setting link to newly installed Java version

Hi, I have Solaris 8 wih Java 1.2.2 as default. I just upgraded it to Java 2 version 1.4. But when I do "java -version: I get following: "Java version "1.2.2" Solaris VM (build Solaris_JDK_1.2.2_05a, native threads, sunjwit) How would I make solaris to look at my new java? If I have to... (4 Replies)
Discussion started by: harjitsingh
4 Replies
Login or Register to Ask a Question