Jython from bathc file?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat May 9 06:29:53 EDT 2015
On Sat, 9 May 2015 09:36 am, vjp2.at at at.BioStrategist.dot.dot.com wrote:
> How do I do this in a .bat file?
> Do I include the Jython or pipe it?
>
> % CLASSPATH=$CLASSPATH:$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar;
> jython
> -Djava.library.path=$RDBASE/Code/JavaWrappers/gmwrapper
> Jython 2.2.1 on java1.6.0_20
> Type "copyright", "credits" or "license" for more information.
>>>> from org.RDKit import *
>>>> from java import lang
>>>> lang.System.loadLibrary('GraphMolWrap')
>>>> m = RWMol.MolFromSmiles('c1ccccc1')
>>>> m.getNumAtoms()
I'm not sure I fully understand your question, but perhaps this will help.
I haven't used Windows for anything like this for decades, but I would
expect something like this:
(1) Create a file containing your Python code and call it "myscript.py" (or
any other meaningful name):
from org.RDKit import *
from java import lang
lang.System.loadLibrary('GraphMolWrap')
m = RWMol.MolFromSmiles('c1ccccc1')
m.getNumAtoms()
(2) Create a .bat file which calls Jython. I don't remember .bat syntax, but
perhaps it is something like this?
CLASSPATH=$CLASSPATH:$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar;
jython -Djava.library.path=$RDBASE/Code/JavaWrappers/gmwrapper myscript.py
And that's it.
Does that work? Any Windows users like to comment?
--
Steven
More information about the Python-list
mailing list