jython

Why does Jython refuse to find my Java package?

流过昼夜 提交于 2019-12-18 04:39:13
问题 I know it's something silly, but for some reason Jython refuses to find javax.swing. I'm using Java 1.6.0_11. This is my start-up script: @echo off "%JAVA_HOME%\bin\java" -Xmx1024M -classpath ".;c:\Projects\Jython2.5.1\jython.jar" org.python.util.jython My output looks like: Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) [Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_10 Type "help", "copyright", "credits" or "license" for more information. >>> import javax.swing

How to call a python method from a java class?

二次信任 提交于 2019-12-18 02:51:39
问题 I am using Jython within a Java project. I have one Java class: myJavaClass.java and one Python class: myPythonClass.py public class myJavaClass{ public String myMethod() { PythonInterpreter interpreter = new PythonInterpreter(); //Code to write } } The Python file is as follows: class myPythonClass: def abc(self): print "calling abc" tmpb = {} tmpb = {'status' : 'SUCCESS'} return tmpb Now the problem is I want to call the abc() method of my Python file from the myMethod method of my Java

Invoking Jython from Python (or Vice Versa)

回眸只為那壹抹淺笑 提交于 2019-12-17 18:56:33
问题 I'm working on a framework right now, part of which requires Jython. I just added some plotting to it using MatPlotLib, without realizing that MatPlotLib is incompatible with Jython. Since these two parts are pretty isolated, and I would be fine running most of the program in Python and passing a small amount of information to the Jython part (or vice versa), I was wondering if there's a simple way to do this, while maintaining the modular nature of the framework. Ideas? 回答1: I have not used

Is there a good NumPy clone for Jython? [closed]

若如初见. 提交于 2019-12-17 18:27:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm a relatively new convert to Python. I've written some code to grab/graph data from various sources to automate some weekly reports and forecasts. I've been intrigued by the Jython concept, and would like to port some Python code that I've written to Jython. In order to do this quickly, I need a NumPy clone

Jython的应用

牧云@^-^@ 提交于 2019-12-16 23:00:59
今天本文围绕主要内容是jython是什么、安装、简单实用。 另外说说我为什么研究jython,研究它是有一个目的的,目的是将python代码转化为jar包以供安卓方面那边人脸识别,虽说目前人脸识别像阿里、腾讯、百度做的都挺好的,有现成的可以使用,不必重复造轮子,但是我们经理需要我们技术人员对于相关的技术必须要了解和熟悉,假设抽象层为1,2,3,4,5,6等,BAT公司做到的抽象我假定为5,5基本上只需调用API就行,其他都不用管,当然了,还有些需要参考一下文档。而我们经理他需要我们做到3或者4,可以自己定义人脸识别的程度,当然了,还是在现在的开源项目基础上,算是一个半自动化造轮子。 接下来开始进入主题。 一、Jython是什么 Jython是一种完整的语言,而不是一个Java翻译器或仅仅是一个Python 编译器 ,它是一个Python语言在Java中的完全实现。Jython也有很多从CPython中继承的模块库。最有趣的事情是Jython不像CPython或其他任何高级语言,它提供了对其实现语言的一切存取。所以Jython不仅给你提供了Python的库,同时也提供了所有的Java类。这使其有一个巨大的资源库。 二、Jython的安装 Jython官方网站:http://www.jython.org/ 我个人是在window10环境下进行安装的,我觉得详细安装,大家可以参考这个链接

Why does my Swing window keep closing itself after a few seconds?

…衆ロ難τιáo~ 提交于 2019-12-14 00:25:31
问题 Edit: In case the multiple tags are confusing, I'm working in Jython. Here's my SSCCE: from javax.swing import JFrame window = JFrame('Test', defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (800, 600)) window.visible = True The window opens, sits there for a few seconds, and then closes. So far the only solution I've found is to add while True: pass to the end, which would seem to indicate that the problem is that window is going out of scope, so it gets cleaned up and has to close. This

White gridlines over image using JES (python)

淺唱寂寞╮ 提交于 2019-12-13 17:28:29
问题 How can I write a program using JES to draw “White” gridlines on an image where the horizontal gridlines are separated by 10 pixels and the vertical gridlines are separated by 20 pixels? 回答1: Yes, surprisingly, addLine(picture, startX, startY, endX, endY) can only draw black lines !? So let's do it by hand. Here is a very basic implementation: def drawGrid(picture, color): w = getWidth(picture) h = getHeight(picture) printNow(str(w) + " x " + str(h)) w_offset = 20 # Vertical lines offset h

Dynamic languages - which one should I choose?

情到浓时终转凉″ 提交于 2019-12-13 13:26:17
问题 Dynamic languages are on the rise and there are plenty of them: e.g. Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc. My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future. But which dynamic language should I focus on learning and why? Which of these will be the preferred language in the near future? 回答1: Learning Ruby or Python (and Scala to a

While Loop Guessing Number Game - Python

回眸只為那壹抹淺笑 提交于 2019-12-13 10:11:50
问题 I'm trying to make a 'guess the number between 1-10' game but the while loops seems to keep running. I want to program to let the user guess a number then display if its too high or low etc then start again automatically (loop) to allow the user to pick again. This code makes it run forever though. Can you guys help me? import random def numberGuess(): printNow("I'm thinking of a number between 1 and 10") guess = 0 # give guess a starting value randNum = random.randrange(1,11) # this line

Jython - importing a text file to assign global variables

雨燕双飞 提交于 2019-12-13 05:52:39
问题 I am using Jython and wish to import a text file that contains many configuration values such as: QManager = MYQM ProdDBName = MYDATABASE etc. .. and then I am reading the file line by line. What I am unable to figure out is now that as I read each line and have assigned whatever is before the = sign to a local loop variable named MYVAR and assigned whatever is after the = sign to a local loop variable MYVAL - how do I ensure that once the loop finishes I have a bunch of global variables such