Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file not found when calling execfile function

 
Dave Patrick
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic