Skip to content

Java version #77

@jayvdb

Description

@jayvdb

Currently jgo only looks for java on the PATH. Some jars only work with certain versions, so it would be nice to detect available Java versions and choose the right one.

Ideally the Java version can be stored in the shortcuts, so the right one can be selected for each shortcut.

e.g. Groovy atm fails on JRE 18

$ jgo org.codehaus.groovy:groovy-groovysh:org.codehaus.groovy.tools.shell.Main
INFO 2022-07-26 16:34:03,211: First time start-up may be slow. Downloaded dependencies will be cached for shorter start-up times in subsequent executions.
Exception in thread "main" java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
        at java.base/java.lang.System.setSecurityManager(System.java:416)
        at java_lang_System$setSecurityManager$2.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
        at org.codehaus.groovy.tools.shell.Main.startGroovysh(Main.groovy:187)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:577)
        at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:193)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:73)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
        at org.codehaus.groovy.tools.shell.Main.main(Main.groovy:156)

I know on Windows all the Java versions and their homes can be found in the registry, and Python on Windows has registry supprt. MacOS makes this discoverable also - subdirectories of a common path IIRC. Linux will have some common approach also, but might be a bit fragmented.

Happy to dig around to come up with a more concrete plan if this idea sounds desirable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions