WnnR
Posts: 3
Joined: Fri Nov 16, 2012 4:03 pm

Classpath calculation; install time or run time?

I'm packaging a relatively simple Java application in a "Per-machine" configuration on Windows 7. The classpath is straightforward, but I need user-specific directories/jars (i.e. path is dependent on who is logged in) added to the classpath as well. The files/directories would be relative to %LOCALAPPDATA%.

I've tried the following:
- Adding the folder in the "files/folders" screen and adding that folder to the classpath (classpath is then 'static' to the LAD of the admin who installed the package, regardless of who is logged in)
- Adding an environment variable with %LOCALAPPDATA% (%LOCALAPPDATA%\path\i\need) and using the "Env Var" option, but the environment variable doesn't resolve %LOCALAPPDATA% and is literal
- Using "Env Var" and type in "%LOCALAPPDATA%\path\i\need"

The last *looks* like it should work looking at the INI file. Running the app from the command line using java and the classpath copied/pasted from the INI file (so java -cp "%LOCALAPPDATA%\path\i\need;blah;blah"), everything works correctly. But when run with the regular EXE, it does not. (I've also verified with a small java program that does nothing but print the classpath; when run with java it prints the user-specific directory, but when run from the exe, it does not.

So... how exactly is the classpath portion in the INI file used/calculated, and how can I accomplish what I need?

Thanks!
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Classpath calculation; install time or run time?

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

In order to achieve what you want you can add a custom Classpath location like this:

Code: Select all

%LOCALAPPDATA%\MyDir\MyJar.jar
using the the [ *.jar... ] button -> "Custom..." option from "Java Product Settings" tab.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
WnnR
Posts: 3
Joined: Fri Nov 16, 2012 4:03 pm

Re: Classpath calculation; install time or run time?

Thanks for the response; I had actually tried that as well, but neglected to put that in my initial post. I tried a path to a specific jar as well as a directory, and neither one worked. (I was actually hoping to specify both a jar *and* a directory, but I'll be happy if I can get just one of those to work). The resulting INI file looks identical to when I tried using 'Env. Var.' method; similarly, if I copy/paste the classpath in the INI file and run the app from the command line using 'java', it works correctly.

(I probably should have put this in my initial post as well; I am on 9.5, if that makes a difference)

I've started to work around it by writing a custom classloader for our app to add the entries at runtime, but that is definitely not the cleanest or easiest solution. Any other recommendations are welcome!

Thanks,
Roberto
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Classpath calculation; install time or run time?

Hello Roberto,

I've tested your scenario and this seems to be an Advanced Installer issue. A fix will be available in a future version of Advanced Installer, thank you for bringing it to our attention. Also, until then if you need this fix you can send us an email to support at advancedinstaller dot com and we can send you a RC containing this fix.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
WnnR
Posts: 3
Joined: Fri Nov 16, 2012 4:03 pm

Re: Classpath calculation; install time or run time?

Daniel --

Thanks for looking into the issue and giving me a piece of my sanity back!

I'll get back to you soon at that e-mail address.

Thanks again,
Roberto
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Classpath calculation; install time or run time?

You're welcome. Glad to help.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Classpath calculation; install time or run time?

Hello,

This was fixed in version 9.8 of Advanced Installer released on December 20, 2012.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”