I am using InstallAnywhere to create executables for my jars for multiple platforms. So install anywhere generates .sh for Unix and .exe for Windows.

But for 1 jar, I want to create batch file instead of exe for Windows. I still want .sh for Unix.

I cannot find any lax property to achieve this. How can I do this?

有帮助吗?

解决方案

There's no way to do that in InstallAnywhere. InstallAnywhere wants to create native execution targets during the installation. The closest you can get is to create a console-only executable.

However, you can write your own batch files and ship them as part of the installation. If you need to include path information (or other install-time information), you can add InstallAnywhere variables like $IA_CLASSPATH$ and replace them at installation time.

Use the "Modify Text File - Single File" Action to modify your batch files (or other text files) at installation.

So that we can test our batch files, we insert positional arguments that get assigned to script variables. During development, we manually supply the positional arguments. At installation time, we replace the positional arguments with values from InstallAnywhere.

For instance:

@echo off
set APP_USER=%1
set APP_PASSWORD=%2
set APP_DIR=%3
set CLASSPATH=%CLASSPATH%;$IA_CLASSPATH$;./lib/myapp.jar

cd %APP_DIR%

java -cp %CLASSPATH% com.example.myapp.Main %APP_USER% %APP_PASSWORD%

We add the "Modify Text File - Single File" Action to our project. We use the "Search and replace strings: " option to replace the positional arguments. In this example, we'd replace %1 and %2 with values collected during the installation and replace %3 with $USER_INSTALL_DIR$. To replace any InstallAnywhere variables (in this case, $IA_CLASSPATH$), check the "Substitute InstallAnywhere variables in file" checkbox.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top