Skip to main content
edited tags
Link
Szabolcs
  • 236.5k
  • 31
  • 641
  • 1.3k
added 76 characters in body
Source Link
Szabolcs
  • 236.5k
  • 31
  • 641
  • 1.3k

Convert a javaJava object to interface via J/Link

I'm trying to use a javaJava library called CDKCDK 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 istis the javaJava equivalent to:

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

As Youyou can see, I need to convert the SmilesParserSmilesParser object to IAtomContainerIAtomContainer 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 IAtomContainerIAtomContainer object (this is an Interface object, not class object) in Mathematica?

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?

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 is 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?

Source Link

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?