Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7063425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:42:43+00:00 2026-05-28T04:42:43+00:00

I am wondering if it is possible to call Python functions from Java code

  • 0

I am wondering if it is possible to call Python functions from Java code using Jython, or is it only for calling Java code from Python?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:42:44+00:00Added an answer on May 28, 2026 at 4:42 am

    Jython: Python for the Java Platform – http://www.jython.org/index.html

    You can easily call python functions from Java code with Jython. That is as long as your python code itself runs under jython, i.e. doesn’t use some c-extensions that aren’t supported.

    If that works for you, it’s certainly the simplest solution you can get. Otherwise you can use org.python.util.PythonInterpreter from the new Java6 interpreter support.

    A simple example from the top of my head – but should work I hope: (no error checking done for brevity)

    PythonInterpreter interpreter = new PythonInterpreter();
    interpreter.exec("import sys\nsys.path.append('pathToModules if they are not there by default')\nimport yourModule");
    // execute a function that takes a string and returns a string
    PyObject someFunc = interpreter.get("funcName");
    PyObject result = someFunc.__call__(new PyString("Test!"));
    String realResult = (String) result.__tojava__(String.class);
    

    As of 2021, Jython does not support Python 3.x

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling python functions from C++. I was wondering if it is possible
I was wondering if it was possible to call some F# code from php.
I'm trying to call a Java program (Stanford Chinese Word Segmenter) from within python.
I've seen that it is possible to call MATLAB functions from VS2010 (VC++). I
I was wondering if there is any possible way to call functions in a
I was wondering if it was possible to call a private method from another
I am just wondering if it is possible to call multiple SQL scripts from
I'm just wondering..is it possible to receive multiple responses from a single ajax call?
I am wondering if it is possible to call a derived class´ function from
I was wondering if it was possible to call a function inside a Perl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.