• Docs »
  • Creating an Example on the command line

Creating an Example on the command lineΒΆ

Let’s start with a very simple OEChem program using command line tools. Open a new file in a text editor called OESample1.java and enter the following code.

import openeye.oechem.*;

class OESample1 {
    public static void main(String [] args) {
        OEGraphMol mol = new OEGraphMol();
        oechem.OEParseSmiles(mol, "c1ccccc1CCCBr");
        System.out.format("mol has %d atoms\n", mol.NumAtoms());

Save the file and let’s compile it from the command line with javac. Note that you can pass the CLASSPATH as an argument to javac or you could declare the CLASSPATH environment variable. In either case, the only thing needed to add is the single jar file.

$> javac -cp oejava-1.8.0-Windows-x86.jar OESample1.java

This should produce OESample1.class if you don’t have any typos. You can then run this sample on the command line using something like:

$> java -cp oejava-1.8.0-Windows-x86.jar:. OESample1
mol has 10 atoms