Blog

JNBridgePro and ClickOnce

There was an interesting support issue here the other day, asking how to use JNBridgePro-enabled application with ClickOnce.  Let’s say you have a nice WinForms app that contains a Java Swing component:

 

sample Swing component embedded in a WinForms app

Now, let’s say you want to publish the application to a Web site, so that users can employ ClickOnce to download, unpack, and run the application on demand.  You’ll need to add additional files to the project that aren’t actually referenced in the .NET code: in this case, the unmanaged files JNBJavaEntry.dll and jawt.dll (that need to be in the execution folder), plus the Java-side components jnbcore.jar and bcel-5.1-jnbridge.jar, and any Java files that need to be in the classpath that aren’t on the target machine.  (These Java files need to be jar files; the ClickOnce mechanism doesn’t seem to be able to reconstruct Java folder hierarchies.)  The project, with the added files, might look like this:

 

Project in Solution Explorer

For each of these additional files, you’ll need to make sure that the “Copy to Output Directory” property is set to “Copy Always”:

 

Properties

You also need to make sure that the configuration file uses relative paths that reference the current runtime folder:

 

Configuration file

Then, build the application and publish it.  You now have a self-contained application that can be downloaded from a Web server and launched using ClickOnce.  That’s all there is to it.

It’s still necessary to have a JNBridgePro license installed on the target machine if you want the application to run past the end of the 30-day evaluation period.  An upcoming version of JNBridgePro will have the ability to package a deployment license file with the downloaded application.  Let us know if that’s a feature of interest to you.