Sponsored Content
Full Discussion: What's my JVM bitness?
Top Forums Shell Programming and Scripting What's my JVM bitness? Post 302535336 by radoulov on Thursday 30th of June 2011 12:06:56 PM
Old 06-30-2011
Quote:
Originally Posted by mohtashims
Hey that works !!

the output looks like

/apps/java/bin/rmiregistry is 32-bit
/apps/wls/bea10/jdk160_05/jre/bin/java is 32-bit
/apps/wls/bea10/jdk160_05/jre/bin/java is 32-bit
/apps/wls/bea10/jdk160_05/jre/bin/java is 32-bit


1) However, can you help me tweak your script to print respective PID next to each java.
This will print the pid:

Code:
pgrep -fl java |
  while read pid exe rest; do
    file "$exe" | 
      fgrep 64-bit &&
        printf '%d %s is 64-bit\n' $pid "$exe" ||
          printf '%d %s is 32-bit\n' $pid "$exe" 
done

Quote:
2) How can I get the java version for a particular PID which I wish to pass as a parameter input in $1
Code:
exe=$(
  ps -p$1 -oargs=
  )

file "$exe" |
  fgrep 64-bit &&
    echo 64-bit ||
      echo 32-bit

Quote:
3) Also, a small explanation of what each line does so I can play with it.

Regards,
ps/pgrep gets the arguments of the process, then execute file for the first argument(...), then grep 64-bit.

Something like this:

Code:
$ ps -p2081 -oargs=
/usr/j2se/bin/java -server -XX:+BackgroundCompilation -Xmx256m -Djava.security.
$ file /usr/j2se/bin/java
/usr/j2se/bin/java:     ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped
$ file /usr/j2se/bin/java | fgrep 64-bit && echo 64 || echo 32
32

Notice that this will return 64 even if a 64-bit java executable is running with -d32 option enabled.
This User Gave Thanks to radoulov For This Post:
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

heap size for JVM!

Hi all, Thanks 'thehoghunter' and 'hugo' for the comments! I've to increase the size of the heap size for AIX 4.3.3. Now what's the command that I've and also is it something similar to growing the file system in Solaris (growfs) (1 Reply)
Discussion started by: i2admin
1 Replies

2. UNIX for Dummies Questions & Answers

Instaling JVM

Hi Everyone I`ve just started with unix can some please help me execute this command via webmin on avirtual server or how do you execute such .bin file this is the error ./j2sdk-1_3_1_15-linux-i586.bin: not found > ls -l total 69124 -rw------- 1 root wheel 8380 May 15 18:01... (2 Replies)
Discussion started by: J.Carlos MC05
2 Replies

3. UNIX for Advanced & Expert Users

inside the JVM

Hi, does anyone know how to find out what's happening inside a JVM on a unix system? Like what processes are running, which ports, memory usage etc. I'm using AIX 5.2 (1 Reply)
Discussion started by: rein
1 Replies

4. AIX

JVM Setting

What should be the idle JVM setting for the LPAR having 16 GB of memory? Currently the JVM setting is set to -Xms1024M -Xmx10240M (1 Reply)
Discussion started by: aajmani
1 Replies

5. AIX

AIX JVM -32 or 64?

Friends, Can any one tell me what command should be used to check whether the JVM in AIX is 32 bit or 64 bit? Thanks, Govindh (2 Replies)
Discussion started by: Govindh.v
2 Replies

6. Web Development

need help about jvm

hi all i want to install apache and tomcat in unix solaris 10 so i need to konw about heap and jvm memory architecture in jdk version 4 and 5 and 6 i want one help me i searched alot and i can't find something helo me (1 Reply)
Discussion started by: maxim42
1 Replies

7. Solaris

jvm memory settings

When i changed jvm memory settings from 3048 to 3548, appsserver could not start. if no change , it was normal. How do we change .otherwise i had a out of swap space error appeared after 3hrs period when do the monitoring of java application. (1 Reply)
Discussion started by: vijill
1 Replies

8. Programming

Porting JVM to MINX

Hi, As you may see from the title, for some reason I need to make running .class files on Minix possible (a compiler is not necessary). So could somebody point me in any direction, suggest some literature or give some advice? Generally, how would you do it? Also how big is this... (8 Replies)
Discussion started by: John117
8 Replies

9. UNIX for Dummies Questions & Answers

JVM Memory

Hi all, I am starting a JVM in unix and when I use ps command on the pid of process starting JVM the output is something like this :- java -Xms32M -Xmx64M -Xmx128M I need to know what would be the value of Xmx in this case. And how to check that this value be picked while starting JVM... (3 Replies)
Discussion started by: Raj999
3 Replies

10. AIX

JVM Process Name

Hi - In AIX, how do I find the Java Virtual Machine Process Name running on a particular machine? I tried ps -ef | grep java but it does not return a process name. Please help. (4 Replies)
Discussion started by: ocbit
4 Replies
All times are GMT -4. The time now is 07:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy