Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect 64-bit Java from the command line?

Tags:

java

windows

Is there any way to get at Java internal properties, such as sun.arch.data.model , from a command line on windows? I need a command to put in a batch script that will detect the java architecture type: 32-bit or 64-bit .

like image 328
djangofan Avatar asked Feb 15 '10 20:02

djangofan


3 Answers

If you are using Sun's VM (and I would suppose other VMs have similar details in their version information), you can check for the string "64-Bit" in the output of "java -version":

java -version 2>&1 | find "64-Bit" >nul:

if errorlevel 1 (
    echo 32-Bit 
) else (
    echo 64-Bit
)
like image 89
jarnbjo Avatar answered Nov 10 '22 12:11

jarnbjo


jarnbjo's script is for Windows. In Unix shell, you can use the following script.

  #!/bin/sh

  BIT=`java -version 2>&1`

  case "$BIT" in
    *64-Bit*)
    echo "64-Bit"
    ;;
    *)
    echo "32-Bit"
    ;;
  esac
like image 32
stoneboy Avatar answered Nov 10 '22 11:11

stoneboy


Here is a prewritten property dump program for you: linky

like image 41
Alexander Torstling Avatar answered Nov 10 '22 13:11

Alexander Torstling