Frequently Asked Questions



Marvin Beans requires at least Java 1.6.




The rotation and the linkage to the sketcher have a negligible contribution to the memory footprint. The largest contributions are from the following:

  • Double buffering of Swing components
  • Size of Molecule objects
  • Large color arrays that store the shades for 3D rendering modes

Even if we provided a "thin" panel without 3D support, it would only enable you to use about twice as many molecules. Then you would run out of memory again because of the double buffering.

The solution is to use only one n-molecule scrollable MViewPane instead of a JTable with n MViewPanes. Then the common data will be stored in only one place (instead of n) and the number of Swing components will be equal to the number of visible molecules which is usually much smaller than n.




I have this problem when I want to get a Molecule from MViewPane: viewPane.getM(0) returns null although I put a molecule in 0. Here is my code:

viewPane.setM(0, "mols-2d/caffeine.mol");
       Molecule m = viewPane.getM(0);

The problem is that you called getM(0) too early. The molecule was not loaded yet, since viewPane.getM(0). MViewPane.setM(int,String) launches a new thread for loading a molecule and the getM(0) method does not wait until this thread is finished.

Thus, there is no guaranty that the molecule loading process is finished until the method returns. This method is generally used in case of loading a huge set of molecules at the same time. If you use the debug option: viewPane.setDebug(2), you can see when the molecule is loaded. Instead of setM(int, java.lang.String) use setM(int, java.io.File, java.lang.String) method.

Using this method will cause setM to wait until molecule loading is finished.

This example shows a similar problem:

viewPane.setM(0, "CN1C=NC2=C1C(=O)N(C)C(=O)N2C");
Molecule m = viewPane.getM(0);

In this case, there are several ways to avoid this problem. For example, you can use the MViewPane.setM(int, Molecule)method:

String smiles="CN1C=NC2=C1C(=O)N(C)C(=O)N2C";
    byte[] buf=smiles.getBytes();
    MolImporter mi = new MolImporter(new ByteArrayInputStream(buf));
    try{
        Molecule mol = mi.importMol(buf);
        viewPane.setM(0,mol);
    }catch(Exception e) {System.err.println(e);}
    Molecule m = viewPane.getM(0);





The MarvinPanel.setParams(String) method is used to set parameters when MarvinPane is initialized (before loading the molecule). You should avoid calling this method after setMol(..) or any other property-setting method.

The difference between a parameter and a property that you can modify a property's value after initialization, while a parameter can only be set once.




Add the -Djava.awt.headless=true option to your Java command, for example:

java -classpath lib/MarvinBeans.jar -Djava.awt.headless=true chemaxon.formats.MolConverter





Please see the example below to get selected atoms.

    Molecule mol = sketchPane.getMol();
    if(mol != null) {
        int size = mol.getAtomCount();
        for(int i = 0;i < size;i++) {
            MolAtom atom = mol.getAtom(i);
            if(atom.isSelected()) {
                System.err.println(i+". atom is selected");
            }
        }
    }





The problem described above may happen if you include only the io package in your project. Even though MolExporter is in the io package, the code necessary for rendering images, for example, PngExport, JpegExport, PdfExport, and so on, is part of the marvin-gui package.

Marvin-gui, on the other hand, depends on io, therefore it is capable of image export. To avoid getting an exception, make sure you include marvin-gui artifact from hub.chemaxon.com.