2

I am building a java application and copying some native dll's before packaging with java packager.

How can I determine in gradle if the build system is 32bit or 64bit so that I can copy the right dll files? At the moment I am manually setting a variable when I remember.

Rob
  • 2,511
  • 2
  • 20
  • 31
  • You create 2 packages. One for 32 bit and one for 64 bit. – Gilbert Le Blanc Feb 01 '16 at 23:43
  • Unfortunately I can't. I am not sure why as I haven't looked into it, but when packaging with Javapackager into an .exe (with inno setup) on a 64bit machine it will install but not run or start on 32bit. I assume it's to do with the .exe wrapper but am not sure yet. – Rob Feb 02 '16 at 00:48
  • @Rob: javapackager, apparently, can only create binaries for the current architecture, so you need to build the binary for 32 bit on a 32 bit architecture. – Pablo Fernandez Sep 01 '17 at 09:18

1 Answers1

2

You can query system property os.arch to determine your operating system architecture and derive how whether you are on 32bit or 64bit OS

If you are concerned with your JVM ( you can run 32bit JVM on 64bit system) use sun.arch.data.model property

Use this task as an example how to access these values

task printProps << {
    println System.properties['os.arch']
    println System.properties['sun.arch.data.model']

}

More information could be found at the below links:

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

How to find the OS bit type

Community
  • 1
  • 1
Vlad
  • 9,180
  • 5
  • 48
  • 67
  • It's not the java I am concerned about, but some dll's that I must package to access sqlserver. thanks for this answer, I will try it out latter – Rob Feb 02 '16 at 00:50
  • It works as advertised. I was not aware that we could do java like things in gradle. Thanks – Rob Feb 02 '16 at 01:38
  • 1
    Gradle is just a bunch of groovy methods / closures with simple executor / scheduler. Gradle script is groovy code. Groovy in turn is built up on top of JVM. So you can call any Java class from your build script http://stackoverflow.com/questions/7567378/access-a-java-class-from-within-groovy you can even call non standard packages and get them downloaded from maven repos https://docs.gradle.org/current/userguide/organizing_build_logic.html – Vlad Feb 02 '16 at 02:44