What's my JVM bitness?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What's my JVM bitness?
# 1  
Old 06-29-2011
Question What's my JVM bitness?

Code:
/apps/wls/bea10/jdk160_05/bin/java -d64 -version
execve(): No such file or directory
Error trying to exec /apps/wls/bea10/jdk160_05/bin/sparcv9/java.
Check if file exists and permissions are set correctly.
Failed to start a 64-bit JVM process from a 32-bit JVM.
Verify all necessary J2SE components have been installed.
(Solaris SPARC 64-bit components must be installed after 32-bit components.)

/apps/wls/bea10/jdk160_05/bin/java -d32 -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)
 
 
uname -a
SunOS mypc 5.10 Generic_144488-07 sun4v sparc SUNW,SPARC-Enterprise-T5220

How can script to check if my JVM is 32 bit or 64 bit?

Note: I need to check this from a remote JVM or unix script as I cant deploy my code on a running JVM.

Regards,
Mohtashim

Last edited by pludi; 06-29-2011 at 11:09 AM..
# 2  
Old 06-29-2011
Just for try, rename

Code:
/apps/wls/bea10/jdk160_05/bin/sparcv9

to

Code:
/apps/wls/bea10/jdk160_05/bin/amd64

maybe it will fix your issue.
# 3  
Old 06-30-2011
Question

I dont need a fix for the above. I need to check if my running PID (JVM) is 32 bit or 64 bit from a unix script.
# 4  
Old 06-30-2011
You may try something like this (untested):

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

For a specific pid use:

Code:
exe=$( ps -p<pid> -oargs= )
file "${exe%% *}" | 
  fgrep 64-bit && 
    echo 64-bit || 
      echo 32-bit


Last edited by radoulov; 06-30-2011 at 12:54 PM..
# 5  
Old 06-30-2011
MySQL

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.

2) How can I get the java version for a particular PID which I wish to pass as a parameter input in $1

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

Regards,
# 6  
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:
# 7  
Old 07-01-2011
Excellect !!! i am good for now... Smilie

---------- Post updated 07-01-11 at 09:29 AM ---------- Previous update was 06-30-11 at 12:14 PM ----------

Current Output

Code:
jdkbit=`file $(ps -p8423 -oargs= | awk '{print $1}') | grep 32-bit && echo 32-bit || echo 64-bit`
echo $jdkbit
/apps/wls/bea10/jdk160_05/jre/bin/java: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped, no debugging information available 32-bit


But I am wanting just "32-bit" or "64-bit" to be assigned to the variable jdkbit in my script. Can you tweak this and help me?

Last edited by radoulov; 07-01-2011 at 01:43 PM.. Reason: Code tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question