Skip to main content
1 of 3

Convert a java object to interface via J/Link

I'm trying to use a java library called CDK with Mathematica's J/Link.

Needs["JLink`"];
ReinstallJava[ClassPath -> $jar];
LoadJavaClass["org.openscience.cdk.silent.SilentChemObjectBuilder"];
sp = JavaNew["org.openscience.cdk.smiles.SmilesParser", 
SilentChemObjectBuilder`getInstance[]];
vabcVolume = JavaNew["org.openscience.cdk.geometry.volume.VABCVolume"];
atom = sp@parseSmiles["C"]

This short code ist the java equivalent to:

SmilesParser   sp  = new
SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer m   = sp.parseSmiles("C");

As You can see, I need to convert the SmilesParser object to IAtomContainer object. In Java the compiler will do it for me. But I guess Mathematica can't do it automatically. Can someone tell me how I can get an IAtomContainer object (this is an Interface object, not class object) in Mathematica?