6

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 .

1
  • 2
    Could you write a small java app to do that and call it from your batch script? Commented Feb 15, 2010 at 20:33

4 Answers 4

6

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
)
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

1

Here is a prewritten property dump program for you: linky

Comments

1

If you install Groovy you can use

groovy -e "System.properties.each{println it}"

for all properties, and

groovy -e "println System.properties['sun.arch.data.model']"

for specific properties.

Installing Groovy is as easy as extracting a zip and add to path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.