self-made applet + MView

User 568550d85a

18-09-2011 14:05:41

Hi there


I would like to add MView functionality to my JApplet. Fundamentally a user enters an ID (JTextField), presses search (JButton) and I would like to have the result molecule in another JPanel.


Now if I try to add an MViewPane to an applet the applet initialization fails/crashes


MViewPane mvp = new MViewPane();

with


The code base can not be determined.
java.lang.reflect.InvocationTargetException

or


java.lang.SecurityException

So I thought that maybe I need to call a different class in case of an applet, but which one? chemaxon.marvin.applet.JMView? chemaxon.marvin.common.swing.MolPanel?


And which library-jars do I require? The ones from the marvin/ subfolder, I believe?


Thanks for help in advance
Lorenz

ChemAxon 7c2d26e5cf

20-09-2011 16:33:07

Is your applet a signed applet?


MViewPane initalization performs certain IO operations that can throw security exception.


Take care that all jars have to be signed if the main jar is signed.

User 568550d85a

21-09-2011 07:09:30










Tamas wrote:

MViewPane initalization performs certain IO operations that can throw security exception.



Well I got it working using this: I added an old unsigned jchem.jar (5.2.1) to the applet's archive tag


<APPLET codebase="classes/" archive="../jchem.jar" code="view.MainApplet" 
width="800" height="550">



and now it works fine. I cannot store structures to file but this seems reasonable since everything is unsigned.


Thus a follow-up question: Let's assume I want to put an applet online which has a small molecule displayer included to display (not store) molecules. Which part of chemaxon software should/may I include and how?


MViewPane with jchem.jar works but I think this is not meant to be put on a website and the jar is quite large (requires long time for applet to start if connection is slow). Or there is the folder "marvin/" but it has many jars and I don't know which one to include (i.e. how to load in an APPLET tag) and which viewer class to use (JMView? but this is a standalone applet already!)


Lorenz

ChemAxon 7c2d26e5cf

23-09-2011 13:53:05

The JChem package includes a full Marvin Applets package (binaries+documentation). It is located in the jchem/marvin directory.


To tell the truth, JChem and Marvin Beans API are designed to desktop integration. We recommend the Marvin Applets package as a web solution. We do not test how to build applet from Marvin Beans and JChem API.


Despite of it, we provide the signed version of both Marvin Beans and JChem binaries as additional packages (see Marvin and JChem download page). These packages are provided for Java Web Start integration where signed content is required to be able to launch Marvin (and certain JChem) applications via browser.


If you need only drawing and visualization functionalities from the ChemAxon API, Marvin Beans package is enough.


Just place MarvinBeans.jar into the classpath. The MANIFEST file of the jar file includes references to other jars where not core classes are located. You need all jars from the package but only the required ones are loaded in at runtime.


If you want to visualize a molecule, there are several options in the API:


chemaxon.marvin.beans.MViewPane - Marvin View component that visualizes one or more molecules.


chemaxon.marvin.MolPrinter - visualize a molecule on the specified graphcs.


chemaxon.formats.MolConverter - convert molecule source into another chemical format or in image. You can use it if you would like to generate molecule images

User 568550d85a

27-09-2011 17:29:39

Aha, so either there is Marvin Applet to run a molecule sketcher or viewer in a dynamical website, or you use Marvin Beans to create a full Application.


So, I see to use Marvin Beans in a self made applet is a bit of mixing up things...


Anyway, I made it work using the following code and using an "old" jchem.jar (version 5.2.1)!


<APPLET codebase="classes/" archive="../jchem_5.2.1.jar" code="view.MainApplet">
</APPLET>

This works fine except that the "save file" options in the viewer are greyed/disabled by default (using a signed applet could help here I think). The problem is if I try to switch to the newest version of jchem using the following tag it does not work any more


<APPLET codebase="classes/" archive="../marvin/MarvinBeans.jar" code="view.MainApplet">
</APPLET>

The error I get is a


class not found Exception (chemaxon.marvin.beans.MViewPane)


But since it works with 5.2.1 I don't mind too much actually.


Tanks for your time


Lorenz

ChemAxon 7c2d26e5cf

30-09-2011 14:03:01

In old Marvin Beans / JChem packages all chemaxon classes was wrapped into a big jar (MarvinBeans.jar or jchem.jar). In these distros only the third party jars (like Inchi, JacoZoom, etc.) were organized into separate jars.


In newer Marvin Beans / JChem packages, the MarvinBeans.jar and the jchem.jar have been devided into several small jars.


In MarvinBeans.jar, only the fundamental part (like molecule representation) has been rested. It refers to external jars where classes of further components (like GUI, calculations, etc.) are located.


The jchem.jar refers to all jars from the MarvinBeans package. It involves only JChem specific core classes and loads further JChem classes from external jars.


Normally, the user do not have to modify his classpath. Only MarvinBeans.jar (by Marvin Beans package) or jchem.jar (by JChem package) has to be in his classpath.
In the MANIFEST file of the above jars there is an internal classpath that tells where related jars are located.


The linking jars has to be in the same directory than the main jar (MarvinBeans.jar or jchem.jar). With other words, you need the full marvinbeans/lib directory (by Marvin Beans) or full jchem/lib directory (by JChem).


Anyway, MViewPane is part of the Marvin Beans package, so the Marvin Beans API is enough for you.


Please check that jchem.jar, MarvinBeans.jar, MarvinBeans-*.jar, jchem-*.jar and third party jars are available in the applet codebase.

User 568550d85a

30-09-2011 15:21:36










Tamas wrote:

The linking jars has to be in the same directory than the main jar (MarvinBeans.jar or jchem.jar). With other words, you need the full marvinbeans/lib directory (by Marvin Beans) or full jchem/lib directory (by JChem).


Anyway, MViewPane is part of the Marvin Beans package, so the Marvin Beans API is enough for you.


Please check that jchem.jar, MarvinBeans.jar, MarvinBeans-*.jar, jchem-*.jar and third party jars are available in the applet codebase.



Well just for curiosity I copied the whole jchem-5.3.8/lib/ folder to the server and included "jchem.jar" into the applet tag and got the following error:


java.lang.SecurityException: Non secure context: JacoZoom library is not accessible
    at chemaxon.marvin.modules.win.Jacozoom.configure(Unknown Source)
    at chemaxon.marvin.modules.win.Jacozoom.start(Unknown Source)
    at chemaxon.marvin.modules.datatransfer.ClipboardHandler.startPermanentResources(Unknown Source)
    at chemaxon.marvin.common.swing.MolPanel.<init>(Unknown Source)
    at chemaxon.marvin.view.swing.ViewPanel.<init>(Unknown Source)
    at chemaxon.marvin.beans.MViewPane.<init>(Unknown Source)
    at chemaxon.marvin.beans.MViewPane.<init>(Unknown Source)
    at view.MainApplet.initComponents(MainApplet.java:71)
    at view.MainApplet.init(MainApplet.java:53)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)




The same is also if I include "MarvinBeans.jar". A bit strange, I think this could eventually be fixed by signing the applet...


But since it is (still) working fine with jchem5.2.1 I'll just leave it.


Thanks for your time
Lorenz

ChemAxon 7c2d26e5cf

30-09-2011 15:37:42

Have you checked that all jars are signed?


A signed applet can loads resources from signed jars.


I suggest you download the marvinbeans-lib-VERSION-signed.zip or the jchem-signed-lib-VERSION.zip. These packages provided the signed version of Marvin Beans or JChem API.