Python _ How to Use python to access Java classes (2)

Source: Internet
Author: User

After downloading the code, you need to install it:

1. First switch to the directory pyjnius-master, and then enter the command: sudo Python setup. py install

2. After the installation is complete, enter the command: sudo make

3. Then enter the command: sudo make tests

After all the preceding three steps are completed, you can write the code and run it. The example is as follows:

Pyjnius

Python module to access Java class as Python class, using JNI.

(Work in progress .)

Quick Overview
>>> From jnius import autoclass >>> autoclass ('java. lang. system '). out. println ('Hello World') Hello World >>> stack = autoclass ('java. util. stack ') >>> stack = stack () >>> stack. push ('hello') >>> stack. push ('World') >>> print stack. pop () World >>> print stack. pop () hello

See https://github.com/kivy/pyjnius

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.