Created
July 4, 2019 18:31
-
-
Save allquixotic/d420ed30a40b6a30308607d6502573e7 to your computer and use it in GitHub Desktop.
javadyn - invoke different Java based on command line argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
JAVA8BIN = "/usr/lib/jvm/zulu-8-amd64/bin/java" | |
JAVA12BIN = "/usr/lib/jvm/zulu-12-amd64/bin/java" | |
#puts ARGV | |
if ARGV.include?("--javaver") then | |
i1 = ARGV.index("--javaver") | |
i2 = i1+1 | |
if ARGV[i2] == "8" then | |
# puts "Using Java 8" | |
arr = ARGV.select { |e| ARGV.index(e) != i1 && ARGV.index(e) != i2 } | |
# puts "Invoking Java with " | |
# puts arr | |
Kernel.exec([JAVA8BIN, JAVA8BIN], *arr) | |
Kernel.exit(0) | |
end | |
end | |
#puts "Using Java 12" | |
Kernel.exec([JAVA12BIN, JAVA12BIN], *ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment