jpackage ROOTDIR variable in a Windows bat file

Alexey Semenyuk alexey.semenyuk at oracle.com
Mon Nov 25 17:47:38 UTC 2019



On 11/25/2019 9:00 AM, Andy Herrick wrote:
>
> On 11/24/2019 10:41 PM, Michael Hall wrote:
>>
>>> On Nov 23, 2019, at 11:45 AM, Michael Hall <mik3hall at gmail.com> wrote:
>>>
>>>
>>>
>>>> On Nov 23, 2019, at 11:22 AM, Kevin Rushforth 
>>>> <kevin.rushforth at oracle.com> wrote:
>>>>
>>>> I just tried this and it worked fine for me:
>>>>
>>>> jpackage --java-options '-Djava.security.policy=$APPDIR/all.policy' 
>>>> ...
>>>>
>>>> (note that there should not be an extra "/app" since $APPDIR points 
>>>> to the app directory).
>>>>
>>>> It generated this in the ApplicationName/app/ApplicationName.cfg file:
>>>>
>>>> [JavaOptions]
>>>> -Djava.security.policy=$APPDIR/all.policy
>>> Maybe something is different about running from a bat. Or I’m 
>>> missing a typo or something.
>>> Command line it seems to get past that error but gets…
>>>
>>> Can not find WiX tools (light.exe, candle.exe)
>>> Download WiX 3.0 or later from….
>>> Error: Invalid or unsupported type: [null]
>>>
>>> This is from a VirtualBox Windows 10 64bit virtual machine.
>>>
>>> The bat file continues to get the same error. I’ll look closer to be 
>>> sure it isn’t an error in my bat.
>>>
>>> On OS X, yes APPDIR works when I remove ‘app’ from the path as you 
>>> indicated.
>> To follow up on this a little bit.
>>
>> I installed the indicated Wix. This in turn required a .Net framework 
>> of I believe 3.5.1. I tried the latest it still didn’t work. I 
>> installed the exact version indicated and it did work, Wix then 
>> installed.
>>
>> I got a command line invocation to run through but still not entirely 
>> successful. If I remember right it indicated something about the 
>> installed incubator runtime not being suitable to run the 
>> application. I probably should of followed up immediately but didn’t. 
>> Sorry, about being sort of vague here. I do sort of wonder about this 
>> being a Windows jpackage dependency. I recently saw I think you on 
>> javafx mention that you didn’t like depending on 3rd party libraries?
>>
>> I got to thinking that I needed something better than the bat file I 
>> was using that wasn’t working at all. It occurred to me I could try 
>> doing something with my own application which is a java shell 
>> intended to invoke things like jpackage. This got me looking closer 
>> at the jpackage parameters including @filename. This seemed a simple 
>> and effective way to do what my bat file was supposed to. Also what I 
>> am thinking of adding to my app. I tried this on Windows.
>>
>> --input ./HalfPipe.app/Contents/app
>> --install-dir ./outputdir
Are you sure you want your app to be installed in 
%ProgramFiles%\outputdir directory?

>>
>> --name HalfPipe
>> --runtime-image "c:/Program Files/Java/jdk-14"
--runtime-image and --add-modules parameters should not be used together.
If Java run-time image is specified with --runtime-image parameter, 
jpackage will not run jlink command to create custom run-time from the 
list of modules specified in --add-modules parameter(s).
So I'd recommend to remove --runtime-image from your input.

- Alexey

>> --main-class us.hall.hp.common.LoaderLaunchStub
>> --add-modules 
>> java.compiler,java.desktop,java.logging,java.management,java.prefs,java.se,java.rmi,java.scripting,java.sql,java.xml,jdk.attach,jdk.jshell
>> --java-options '-Xmx1024m -Djava.security.policy=$APPDIR/all.policy 
>> -Dconsole=pane'
>> --main-jar halfpipe.jar
>>
>> Notice the exclusive use of forward slash as per your earlier. This 
>> is run against a successfully built OS X version of the app. This 
>> currently gets…
>>
>> C:\Users\mik3h\Documents\halfpipe_port>jpackage @jpkg.txt
>> WARNING: Using incubator modules: jdk.incubator.jpackage
>> java.nio.file.FileAlreadyExistsException: 
>> C:\Users\mik3h\AppData\Local\Temp\jdk.incubator.jpackage13266515172329575129\images\win-msi.image\HalfPipe\app\HalfPipe.cfg
>>
>> Possibly a simple error on my part but it is not yet clear to me what.
>
> 1.) - you might learn more by running with --verbose ('jpackage 
> @jpkg.txt --verbose') if you can sift thry the excess output.
>
> 2.) in my test app I need to escape the '$' in front of APPDIR because 
> command is being processed first by shell, for example I have: (  
> --java-options '-splash:\$APPDIR/boinga.jpg' )
>
> still - I don't understand how you get a FileAlreadyExists on a cfg 
> file in the temp directory.
>
> Oh - wait - I see the problem!
>
> ----------------------------------------
>
> you are using the $APPDIR of one run of jpackage (albeit from a 
> different OS) as the input dir of another run.
>
> the APPDIR contains all the files from the input dir, plus a config 
> file <app name>.cfg
>
> so after copying all the files from the input dir, there is already a 
> HalfPipe.cfg in the app dir before we try to create one.
>
> I can reproduce this by adding an empty file "simple.cfg" to my input 
> dir creating an app named simple.
>
> This is probably a bug we can fix - but you should be able to work 
> around it by removing
>
> ./HalfPipe.app/Contents/app/HalfPipe.cfg before running windows build.
>
> /Andy
>
>>
>>
>>



More information about the core-libs-dev mailing list