4 Replies Latest reply on Jun 2, 2010 9:37 AM by Matt Kreger

    extended object that shows all installed java instances?

    Matt Kreger

      I need an extended object that show all instances of java installed on a managed device.  I could simply run 'java -version' but that will only show me what's first in the path.

       

      I just figured I'd ask if anyone already has something to do this before I try to figure it out on my own.  I need it for Windows, Solaris, and Red Hat.

       

      Thanks,

      Matt

        • 1. Re: extended object that shows all installed java instances?
          Bill Robinson

          I've got something like this.  basically the approach is to run a 'find' against the target system looking for 'java' or 'java.exe' and then do a 'java -version' on each one.  Probably something like:

           

          Unix:

          Cd //$server

          For java in `find / -type f -name 'java'`

          Do

          Echo "$java: `Nexec -e sh -c "$java -version"`"

          Done

           

          Windows

          Cd //$server

          For java in `find / -type f -name "java.exe"

          Do

          Winpath="c:`echo $java | sed "s|/|\|g"

          Echo "$java: `nexec -e cmd /c "$winpath -version"

          Done

           

          Though on windows we'll have to figure out a way to list the disks (c, d, e , etc) and search each of them.  I'm not 100% sure on that regex above for windows.

          1 of 1 people found this helpful
          • 2. Re: extended object that shows all installed java instances?
            Saurabh Kashikar

            I haven't tried windows..

             

            But Bill this is what I wrote for *Unix

             

            for java in `find / -name java`; do echo $java | grep bin; if ; then $java -version; fi; done;

             

            And kept extended object as remote execution..

            But the o/p column just gives just the path and not the version. Capturing version is a real pain.

             

            Any clue??

            1 of 1 people found this helpful
            • 3. Re: extended object that shows all installed java instances?
              Matt Kreger

              Thanks.  With a lot of help from Stephan, this is what is working for me on Linux / Solaris:

               

              server=$1
              for java in `nexec $server find / -type f -name 'java' 2>/dev/null`
              do
                  echo "$java: `nexec -i $server "$java -version"`" | awk '/java/ {print $1 " " $4}'
              done
              exit 0

               

              the exit is necessary because there are some instances of java that are not set to executable. Using the name space value grammar with this awked output gives me path and version, with version being the actual version number or "Permission"

               

              Now to figure out how to do the same thing searching all local drives on Windows...

              • 4. Re: extended object that shows all installed java instances?
                Matt Kreger

                changed it up a bit.  added  -perm -100 to the find statement and removed the exit 0

                 

                using -100 as opposed to 100 makes it bit-wise ANDed with the permissions of the file so it should show any file root has execute on

                 

                Not sure how to do that to check for x-- -x- and --x though.  Google is only gettnig me so far.  I'm a Windows guy for pete's sake.