mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Advanced Licensing from within a Java application

Has anyone successfully used Advanced Licensing from within a Java application? My approach has been to use "Trial.dll" and Java code given by cosmin in the AI 6.7 Licensing and Trial/registration* thread. However, all attempts fail with the following exception.

Code: Select all

Exception in thread "main" java.lang.UnsatisfiedLinkError: AILicenseTest.DisplayRegistration()S
	at AILicenseTest.DisplayRegistration(Native Method)
	at AILicenseTest.main(AILicenseTest.java:10)
It seems that the DLL is loaded but the DisplayRegistration() method cannot be found. I'm getting nowhere and would appreciate any assistance.

* http://www.advancedinstaller.com/forums ... f=2&t=8432
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: Advanced Licensing from within a Java application

Here is the source code which produces the exception:

Code: Select all

public class AILicenseTest {

	public native static short DisplayRegistration();

	public static void main(String[] args) {

		System.load("C:\\Demo.dll");

		short ret = 2;
		ret = DisplayRegistration();
		if (ret == 0) { // the user has provided a valid registration key
			System.out.println("Thanks for being a wonderful customer.");
		} else {
			System.out.println("Thank you for trying our software.");
		}
	}
}
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Advanced Licensing from within a Java application

Hi,

Did you add the Java Product in the "Trialware Java Products" section of the Options tab in the Licensing page? Please note that this is necessary in order to include the licensing feature into your Java Product.

If it's added, please send us the AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: Advanced Licensing from within a Java application

Hi Cosmin,

No, I did not. I do not have a Java Product, per se. My application is written in Java but it is started by third-party executable. I haven't needed to use the AI launcher executable and thus have no Java Product.

Do I still need to create a Java Product in order to use the "Trial.dll" from within my Java application even if I will not use the AI launcher executable?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Advanced Licensing from within a Java application

Hi,

Since you are not using a Java Product, you need to manually call the appropriate functions from the DLL used by the licensing feature. Please note that the User Guide contains the Integrate the Licensing support how-to which may help you. The logic of this how-to and the sample code needs to be adapted to your application.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: Advanced Licensing from within a Java application

Cosmin,

Indeed, I believe I was attempting just that; I was trying to use the Java code to manually call the DLL as you outlined in your post last month. Are you aware of anyone successfully using that approach? Do you have any simple, working examples?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Advanced Licensing from within a Java application

Hi,

Please note that the post you mentioned explained how to use the licensing feature in a Java Product. Since you are not using a Java Product in Advanced Installer and you are simply adding the files in the "Files and Folders" page, you need to load the DLL and call functions from it manually, like any other application. The how-to I mentioned explains how to do this for a C++ application (you can adapt it for Java).

Using a Java Product in Advanced Installer automatically includes part of the licensing feature in the application, making the licensing integration more easily. Only in this case you can use the approach I explained in that thread.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: Advanced Licensing from within a Java application

Hi everyone,

Great news. I figured it out! Have a look at my post for details and code example. Thanks for your help, Cosmin.

http://codeaweso.me/2009/02/use-advance ... plication/

Hope others find this useful.

Return to “Common Problems”