Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLTK fails to find the Java executable

Tags:

I am using NLTK's nltk.tag.stanford, which needs to call the java executable.

I set JAVAHOME to C:\Program Files\Java\jdk1.6.0_25 where my jdk is installed, but when run the program I get the error

"NLTK was unable to find the java executable! Use the config_java() or set the JAVAHOME variable" 

Then I spent 3 hours on debugging it and tried

config_java("C:/Program Files/Java/jdk1.6.0_25/")  config_java("C:/Program Files/Java/jdk1.6.0_25/bin/") and those without the ending "/".  

However the nltk still cannot find it.

Anyone has idea about what's going wrong? Thanks a loooot!

like image 796
Thomas Chu Avatar asked Sep 13 '11 15:09

Thomas Chu


Video Answer


1 Answers

If setting the JAVA_HOME environment doesn't help you, try this:

config_java() did not work for me. I add the following lines to my code and it worked:

import os java_path = "C:/Program Files/Java/jdk1.7.0_11/bin/java.exe" os.environ['JAVAHOME'] = java_path 

I am running Windows 7 64-bit

like image 175
Alan Avatar answered Oct 03 '22 01:10

Alan