wood burning stoves 2.0*
The moose likes Jython/Python and the fly likes file not found when calling execfile function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "file not found when calling execfile function" Watch "file not found when calling execfile function" New topic
Author

file not found when calling execfile function

Dave Patrick
Greenhorn

Joined: May 23, 2011
Posts: 2
Hi,
I am trying to execute the following code from Java:



I have a python script called SendGridEnvelope.py that gets packaged in my WAR under WEB-INF/classes.

I keep getting a file not found exception because the execfile function is looking for the Python script under my Jboss/bin directory. I am using Jython by the way.

Does anyone know why the execfile method is looking for the python script in the Jboss/bin dir and how to change this?

Thanks,
David
Matt Cartwright
Ranch Hand

Joined: Aug 25, 2008
Posts: 149

'execfile(String arg0)' searches the current working directory, you need to specify the absolute path and I always add the extension (.py)...

you could open the file as a java.io.InputStream and pass it to 'execfile(InputStream arg0)'

HTH
Matt
 
Consider Paul's rocket mass heater.
 
subject: file not found when calling execfile function
 
Similar Threads
How to call a Python method form Java class
AttributeError when calling pyhton scripts from java class
Help - How to I tell java where my jython.py script is located in the Directory
Calling python function from java
Executing Jython script from java and accessing resulting object