Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Support for a new syntax in JVMVersion field to specify both min and max Java version #51

Closed
tofi86 opened this issue Nov 16, 2017 · 3 comments
Assignees
Milestone

Comments

@tofi86
Copy link
Owner

tofi86 commented Nov 16, 2017

to specifiy minimal 1.7 and max 1.8 but not Java 9

e.g.

  • 1.7+ for Java 7, 8, 9
  • 1.7;1.8* for Java 7, 8
  • 1.8;9.0 for Java 8* up to exactly 9.0 (but not 9.0.*)
  • 1.8;9.0* for Java 8* and 9.0.* but not 9.1.*
@tofi86 tofi86 added this to the Version 2.2 milestone Nov 16, 2017
@tofi86 tofi86 self-assigned this Nov 16, 2017
@tofi86 tofi86 removed this from the Version 2.2 milestone Jan 7, 2018
@tofi86
Copy link
Owner Author

tofi86 commented Jan 7, 2018

It's not as easy to implement as I thought...

Splitting the JVMVersion is easy:

	# read the Java version we want to find
	JVMVersion=$(plist_get_java ':JVMVersion' | xargs)
	if [[ ${JVMVersion} == *";"* ]]; then
		minMaxArray=(${JVMVersion//;/ })
		JVMVersion=$(echo ${minMaxArray[0]} | sed 's/+//')
		JVMMaxVersion=$(echo ${minMaxArray[1]} | sed 's/+//')
		stub_logger "[JavaRequirement] JVM minimum version: ${JVMVersion}"
		stub_logger "[JavaRequirement] JVM maximum version: ${JVMMaxVersion}"
	fi

I already removed a trailing + as it would conflict with the min/max system.

But then finding an installed Java version which is between min and max is hard.
Also because the system tool /usr/libexec/java_home does not support a max version parameter.

@tofi86
Copy link
Owner Author

tofi86 commented Jan 29, 2018

So I wrote this new piece of code over the past couple of days:
https://gist.github.com/tofi86/3d5973f8cb259f07207451d051a52ae1

Given a $min and (optionally) a $max version requirement it finds all the JVMs on the system (JDK and JRE, no preference) and compares its version number to the min/max requirement.

Look at the gist comments for examples. Should work quite well :)

Integration on development is still missing and to come in the next couple of days.

tofi86 added a commit that referenced this issue Feb 12, 2018
See issue #51 for examples how to use this feature
tofi86 added a commit that referenced this issue Feb 12, 2018
@tofi86
Copy link
Owner Author

tofi86 commented Feb 12, 2018

Solved with commit 02c2c24.

Supported syntax is

  • 1.7;1.8* for Java 7, 8
  • 1.8;9.0 for Java 8* up to exactly 9.0 (but not 9.0.*)
  • 1.8;9.0* for Java 8* and 9.0.* but not 9.1.*

@tofi86 tofi86 closed this as completed Feb 12, 2018
@tofi86 tofi86 added this to the Version 2.2 milestone Feb 12, 2018
JacksonBailey added a commit to JacksonBailey/jd-gui that referenced this issue Mar 10, 2022
For me running Java 17 with this results in a crash. I am not sure why.
I did not check 12, 13, 14, 15, or 16 since they are not LTS releases.

See [here][1] for info on the syntax for the version range. This will
accept not only 11.0.x but also 11.x (not that they ever put anything
besides 0 there nowadays).

[1]: tofi86/universalJavaApplicationStub#51 (comment)
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

1 participant