Java invoke Python, there is "unresolved compilation problem, Pythoninterpreter cannot resolve to type"

Source: Internet
Author: User

In the Java project file, to invoke some of the results of Python processing, you can use the Jython jar package, which you can use to download the latest Jar packs in http://www.jython.org/downloads.html, and you can choose a lower version if you are stable.
After downloading into the project engineering directory and configuration, wrote a test code as follows:

Import Org.python.util.PythonInterpreter;
Import org.python.core.PyException;  
public class MyTest {

    /**
     * Test
     /public static void main (string[] args) throws Pyexception {  
            Pytho Ninterpreter interp = new Pythoninterpreter ();  
            Interp.execfile ("python/tt.py");
            Interp.close ();
        }  

Click Run to report an error: Exception in thread "main" Java.lang.Error: Unresolved compilation problem: Pythoninterpreter cannot resolve to type syntax error ..., as follows:

According to the hint, can be judged is Jython interpreter out of the question, choose Eclipse->windows->preference->pydev->interpreter->jython interpreter, Click New to add the downloaded Jython jar package, as shown in the figure:

When you're done, and then click Run, you can get a handle on the Python statement, as shown in figure:

There is an output statement in tt.py, there is a warning of character encoding, there is no effective method processing, the version reduced to 2.5 will not be prompted.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.