Reputation: 1803
The .NET assembly PE header has a target platform for 32-bit / 64-bit which is used when the assembly use native interop like P/Invoke (otherwise it would be Target=AnyCPU
).
Is there any equivalent for Java when the Java application has an interface to some native interface through JNI? The JNI has to be either compiled for 32-bit or 64-bit.
Is there an article explaining Java 64-bit architecture and development? I wasn't able to find one.
Upvotes: 1
Views: 447
Reputation: 11
You can detect 64-bit by using:
public static final boolean is64bit = (System.getProperty("sun.arch.data.model").indexOf("64") != -1)
You can also start Java in 32 or 64-bit by using -d32
or -d64
.
If this for a web or desktop application there may be a way of specifying it from the manifest file.
Upvotes: 1
Reputation: 206786
You can look at the system property os.arch
:
String osArch = System.getProperty("os.arch");
Unfortunately the possible values for this property are not documented, but you might try it out on different systems to see what it returns (using Sun JDK 6 update 20 on my 64-bit system it returns amd64
).
See the API documentation of java.lang.System.getProperties()
for other available system properties.
Upvotes: 0