Advanced Licensing from within a Java application

Having trouble running Advanced Installer? Got a bug to report? Post it all here.

Advanced Licensing from within a Java application

Postby mchristianson » Tue Jan 13, 2009 7:11 pm

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/viewtopic.php?f=2&t=8432
mchristianson
 
Posts: 11
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, AZ, USA

Re: Advanced Licensing from within a Java application

Postby mchristianson » Tue Jan 13, 2009 7:18 pm

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.");
      }
   }
}
mchristianson
 
Posts: 11
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, AZ, USA

Re: Advanced Licensing from within a Java application

Postby cosmin » Wed Jan 14, 2009 11:46 am

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
http://www.advancedinstaller.com/
cosmin
 
Posts: 4986
Joined: Tue Jul 10, 2007 6:39 pm

Re: Advanced Licensing from within a Java application

Postby mchristianson » Wed Jan 14, 2009 7:22 pm

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?
mchristianson
 
Posts: 11
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, AZ, USA

Re: Advanced Licensing from within a Java application

Postby cosmin » Thu Jan 15, 2009 1:17 pm

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
http://www.advancedinstaller.com/
cosmin
 
Posts: 4986
Joined: Tue Jul 10, 2007 6:39 pm

Re: Advanced Licensing from within a Java application

Postby mchristianson » Thu Jan 15, 2009 7:08 pm

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?
mchristianson
 
Posts: 11
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, AZ, USA

Re: Advanced Licensing from within a Java application

Postby cosmin » Fri Jan 16, 2009 9:31 am

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
http://www.advancedinstaller.com/
cosmin
 
Posts: 4986
Joined: Tue Jul 10, 2007 6:39 pm

Re: Advanced Licensing from within a Java application

Postby mchristianson » Fri Feb 13, 2009 4:42 am

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://blog.christiansons.net/2009/02/u ... plication/

Hope others find this useful.
mchristianson
 
Posts: 11
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, AZ, USA


Return to Common Problems

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 3 guests