How to use ElementalAnalyserPlugin?

User ceff79a960

18-04-2008 15:33:50

hello all, I am a student who wants to build a chimical database , and I want to save the exacmass and the formula to database, and I have tried to use the API of ElementalAnalyserPlugin, but it came out always the erreurs "Unhandled exception type PluginException "





here is my code :








package masstest;





import chemaxon.formats.*;


import chemaxon.marvin.plugin.*;


import chemaxon.struc.*;


import java.util.Properties;


import java.lang.*;


import java.io.*;


import chemaxon.calculations.*;





public class calcul {





public static void main(String[] args) {


ElementalAnalyserPlugin elemanal = new ElementalAnalyserPlugin();





// run plugin on target molecules


MolImporter mi = new MolImporter(input.smiles);


Molecule mol = null;


while ((mol = mi.read()) != null) {





// set target molecule


elemanal.setMolecule(mol);





double exactMass = elemanal.getExactMass();





String formula = elemanal.getFormula();





// now use the results...


}


}


}








Can anyone help me ? thank you

ChemAxon e08c317633

21-04-2008 09:33:33

Hi,





You have two options:


1. catch the exception (surround with try/catch block the code part that trows exception),


2. add "throw PluginException" after the "public static void main(String[] args)" method declaration.





You may find useful these readings:


1. The Java Tutorials, Lesson: Exceptions


2. Bruce Eckel, Thinking in Java, 3rd ed. Revision 4.0, Chapter 9: Error Handling with Exceptions





I hope this helps.





Zsolt