JEP 330
John Rose
john.r.rose at oracle.com
Sat Jun 2 02:01:09 UTC 2018
On Jun 1, 2018, at 1:26 PM, forax at univ-mlv.fr wrote:
>
> De: "John Rose" <john.r.rose at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "cay horstmann" <cay.horstmann at gmail.com>, "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Jeudi 31 Mai 2018 22:55:14
> Objet: Re: JEP 330
> On May 31, 2018, at 1:36 PM, Remi Forax <forax at univ-mlv.fr <mailto:forax at univ-mlv.fr>> wrote:
>
> or just put the jar near the shebang file :)
>
> That raises an interesting question: How does the shebang script refer to a side file
> in the same directory? In /bin/sh we would say something like "${0%/*}/side.jar".
> I suppose there is a JVM property which exposes that command line argument already;
> if not there should be. Then an API like java.nio.file.Path can help find the side file.
>
> Amusingly, it's easier to get a jar from a server somewhere on the planet than to get a jar from the same directory of a script :)
This might work:
System.getProperty("sun.java.command")
At least, it works today to get the class name. Who knows whether
it will also give you the script file name. And note the ominous "sun."
prefix.
Seems like this use case could use some love. Scripts locating
themselves require a little work from the launcher, well repaid
by portability (relocatability) of the script.
As an idealist, I might want Class.getResourceAsStream to return
the contents of a side file to the script file. But it's more likely to
return null, given the strategy of compiling the script into a temporary
artifact in an undisclosed location.
— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180601/057c3041/attachment.html>
More information about the compiler-dev
mailing list