Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added support for adding default launch arguments #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
fvarrui merged 1 commit into javapackager:devel from bleuthoot-sven:master
Jan 22, 2025

Conversation

@bleuthoot-sven
Copy link

@bleuthoot-sven bleuthoot-sven commented Nov 24, 2024

Adds support for launching an application with default arguments.

NOTE: This currently only works for MacOS and Linux. I was unable to get it to work for Windows. I have tried editing both the startup.vbs.vtl to apply the arguments or editing the ini.vtl file to apply the arguments, but it doesn't seem to work. I have no idea what the correct way to do this would be.

I would need some help for fixing this issue so that default arguments also work on Windows before this can be merged.

startup.vbs.vtl attempt
#set ($appArgs = $StringUtils.join($info.appArgs, " "))
' Windows startup script generated by JavaPackager plugin
' Runs an executable file (exe, bat, cmd, ...)
Function Run(file, arguments)
 If FileExists(file) Then
 Set WshShell = CreateObject("WScript.Shell")
 WshShell.Run Chr(34) & Chr(34) & Chr(34) & file & Chr(34) & Chr(34) & Chr(32) & arguments & Chr(34), 0
 Set WshShell = Nothing
 End If
End Function
' Checks if a file exists
Function FileExists(FilePath)
 Set fso = CreateObject("Scripting.FileSystemObject")
 If fso.FileExists(FilePath) Then
 FileExists=CBool(1)
 Else
 FileExists=CBool(0)
 End If
End Function
#if ($info.bootstrapFile)
' Runs bootstrap script if exists
Run "scripts\\${info.bootstrapFile.name}"
#end
' Runs app executable
Run "${info.executable.name}", "${appArgs}"
ini.vtl attempt
main.class=${info.mainClass}
log.level=error
ini.override=true
classpath.1=libs\*.jar
classpath.2=${info.jarFile.name}
#set ($classpathCounter=3)
#foreach ($cp in $info.classpaths)
classpath.${classpathCounter}=$!{cp}
#set ($classpathCounter=$classpathCounter+1)
#end
#if ($info.bundleJre)
vm.location=${info.jreDirectoryName}\\${info.winConfig.vmLocation}
#else
vm.location=%JAVA_HOME%\bin\client\jvm.dll|%JAVA_HOME%\bin\server\jvm.dll
#end
#if (!$info.bundleJre && $info.jreMinVersion)
vm.version.min=${info.jreMinVersion}
#end
#if ($info.useResourcesAsWorkingDir)
working.directory=.
#end
#set ($vmArgsCounter=1)
#foreach ($vmArg in $info.vmArgs)
vmarg.${vmArgsCounter}=$!{vmArg}
#set ($vmArgsCounter=$vmArgsCounter+1)
#end
#set ($appArgsCounter=1)
#foreach ($appArg in $info.appArgs)
arg.${appArgsCounter}=$!{appArg}
#set ($appArgsCounter=$appArgsCounter+1)
#end
[ErrorMessages]
java.not.found=A suitable version of Java could not be found on your system. Please contact ${info.organizationName}.
java.failed=Java failed to startup successfully. Please contact ${info.organizationName}.

Closes #305

@fvarrui fvarrui merged commit 543d77a into javapackager:devel Jan 22, 2025
2 checks passed
Copy link
Collaborator

fvarrui commented Jan 22, 2025

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fvarrui fvarrui fvarrui approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /