Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
ChemAxon Java Classes with Matlab...
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message

Joined: 21 Sep 2011
Posts: 3

View user's profile

Back to top
Link to postPosted: Tue Nov 26, 2013 1:17 amPost subject: ChemAxon Java Classes with Matlab... Reply with quote

Hello All!

I'm sorry if this is in the wrong section, I'm simply putting this in the same section that a similar question was placed in.

I'm having a lot of trouble using ChemAxon java classes in Matlab. Even after using the commands on the aforementioned similar question, I cannot seem to get the program to function correctly. They refer to an article via a dead link, but I've found it here.

I imported the jar files with the following command in MatLab

% Generate the list of jar files
jarDirectory = 'C:\Program Files (x86)\ChemAxon\JChem\lib';
dirResult = dir([jarDirectory, filesep, '*.jar']);
jars = cellfun( @(name)fullfile(jarDirectory, name), {}, 'UniformOutput', false );

% Add jars to the dynamic classpath
javaaddpath( jars );

% Check classpath

The "javaclasspath('-dynamic') command returns all of the .jar files that have been loaded by matlab, and I see all of ChemAxon's jar files. I should also note that I've also extracted all of the class files out of the jar files as well already, according to pkovac's instructions and tried everything on that page... to no avail :(

I'll simply paste what tardebut has inputted and return what my machine returns... in the hopes that someone knows what to do. ._.

>> chemaxon.formats.MolImporter.importMol("C1C(=O)CCC1").getAtomCount()
Error: The input character is not valid in MATLAB statements or expressions.

>> chemaxon.formats.MolImporter.importMol('C1C(=O)CCC1').getAtomCount()
No method 'importMol' with matching signature found for class 'chemaxon.formats.MolImporter'.

>> inst = chemaxon.formats.MolImporter
No constructor 'chemaxon.formats.MolImporter' with matching signature found.

>> which importMol
importMol is a Java method  % chemaxon.formats.MolImporter method

>> methods('chemaxon.formats.MolImporter')
Methods for class chemaxon.formats.MolImporter:


>> inst.importMol = 'C1C(=O)CCC1';
(It does something... it creates a variable 'inst' that has the field 'importMol' filled with 'C1C(=O)CCC1'. This is a different result than what the other guy got. I think it has to do with "public classes" but I'm not sure what that means on Java :/)

>> inst.importMol('C1C(=O)CCC1')
Index exceeds matrix dimensions.

>> inst.importMol('C1C(=O)CCC1').getAtomCount()
Improper index matrix reference.

>> importMol('C1C(=O)CCC1').getAtomCount()
Undefined variable "importMol" or class "importMol".

.... So yeah, any help would be greatly appreciated!

ChemAxon personnel
Joined: 14 Jan 2011
Posts: 78

View user's profile

Back to top
Link to postPosted: Fri Nov 29, 2013 2:16 pmPost subject: Reply with quote

Dear Yura,

I don't know why the old example doesn't work. Probably something has changed in process of Java method calling in MatLab.
But the following code works fine:

mol = chemaxon.formats.MolImporter.importMol('C1C(=O)CCC1');

Best regards,

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1

To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum