From bsf-userjoshua86@example.net Thu Dec 22 22:12:01 2005
Return-Path: <bsf-userjoshua86@example.net>
Delivered-To: joshua86@example.net
Received: (qmail 64896 invoked from network); 22 Dec 2005 22:12:00 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155)
  by minotaur.apache.org with SMTP; 22 Dec 2005 22:12:00 -0000
Received: (qmail 67122 invoked by uid 500); 22 Dec 2005 22:12:00 -0000
Delivered-To: joshua86@example.net
Received: (qmail 67102 invoked by uid 500); 22 Dec 2005 22:11:59 -0000
Mailing-List: contact joshua86@example.net; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:joshua86@example.net>
List-Help: <mailto:joshua86@example.net>
List-Post: <mailto:joshua86@example.net>
List-Id: "Bean Scripting Framework users" <bsf-user.jakarta.apache.org>
Reply-To: "Bean Scripting Framework users" <joshua86@example.net>
Delivered-To: mailing list joshua86@example.net
Received: (qmail 67091 invoked by uid 99); 22 Dec 2005 22:11:59 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (83.161.120.155)
    by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2005 14:11:59 -0800
X-ASF-Spam-Status: No, hits=0.0 required=10.0
	tests=
X-Spam-Check-By: apache.org
Received-SPF: neutral (asf.osuosl.org: local policy)
Received: from [83.161.120.155] (HELO mout0.freenet.de) (83.161.120.155)
    by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Dec 2005 14:11:58 -0800
Received: from [83.161.120.155] (helo=mx5.freenet.de)
	by mout0.freenet.de with esmtpa (Exim 4.60)
	(envelope-from <joshua86@example.net>)
	id 1EpYev-00043E-R5
	for joshua86@example.net; Thu, 22 Dec 2005 23:11:37 +0100
Received: from k8ca8.k.pppool.de ([83.161.120.155] helo=orbital.zellner.org)
	by mx5.freenet.de with esmtpsa (ID joshua86@example.net) (TLSv1:AES256-SHA:256) (Exim 4.60 #3)
	id 1EpYev-0001wr-LG
	for joshua86@example.net; Thu, 22 Dec 2005 23:11:37 +0100
Received: from joze by orbital.zellner.org with local (Exim 4.54)
	id 1EpYfp-0008DC-Qc
	for joshua86@example.net; Thu, 22 Dec 2005 23:12:33 +0100
Date: Thu, 22 Dec 2005 23:12:33 +0100
From: Johannes Zellner <joshua86@example.net>
To: joshua86@example.net
Subject: jython problem
Message-ID: <joshua86@example.net>
Mail-Followup-To: joshua86@example.net
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Disposition: inline
X-Accept-Language: de en
User-Agent: Mutt/1.5.11
X-Virus-Checked: Checked by ClamAV on apache.org
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N

Hello,

the following program

    import org.apache.bsf.*;

    public class Test {

        public static void main(String args[]) throws BSFException {

            Object obj = new BSFManager().eval("jython", "<script>", 0, 0,
                    new String("import sys\nsys.stderr.write('hello from jython\n')\n"));

        }
    }

fails with:

Exception in thread "main" org.apache.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  (no code object) at line 0
SyntaxError: ('invalid syntax', ('<string>', 1, 1, 'import sys'))

        at org.apache.bsf.engines.jython.JythonEngine.eval(Unknown Source)
        at org.apache.bsf.BSFManager$5.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.bsf.BSFManager.eval(Unknown Source)
        at Test.main(Test.java:7)

what's wrong? -- Or: how can I get jython in bsf working?

-- 
Johannes

---------------------------------------------------------------------
To unsubscribe, e-mail: joshua86@example.net
For additional commands, e-mail: joshua86@example.net


From bsf-userjoshua86@example.net Wed Dec 28 18:10:02 2005
Return-Path: <bsf-userjoshua86@example.net>
Delivered-To: joshua86@example.net
Received: (qmail 41657 invoked from network); 28 Dec 2005 18:10:02 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155)
  by minotaur.apache.org with SMTP; 28 Dec 2005 18:10:02 -0000
Received: (qmail 70040 invoked by uid 500); 28 Dec 2005 18:10:02 -0000
Delivered-To: joshua86@example.net
Received: (qmail 69841 invoked by uid 500); 28 Dec 2005 18:10:00 -0000
Mailing-List: contact joshua86@example.net; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:joshua86@example.net>
List-Help: <mailto:joshua86@example.net>
List-Post: <mailto:joshua86@example.net>
List-Id: "Bean Scripting Framework users" <bsf-user.jakarta.apache.org>
Reply-To: "Bean Scripting Framework users" <joshua86@example.net>
Delivered-To: mailing list joshua86@example.net
Received: (qmail 69829 invoked by uid 99); 28 Dec 2005 18:10:00 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (83.161.120.155)
    by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2005 10:10:00 -0800
X-ASF-Spam-Status: No, hits=0.0 required=10.0
	tests=
X-Spam-Check-By: apache.org
Received-SPF: pass (asf.osuosl.org: local policy)
Received: from [83.161.120.155] (HELO sslmail1.wu-wien.ac.at) (83.161.120.155)
    by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Dec 2005 10:09:59 -0800
Received: from [83.161.120.155] (abt-wi-002.wu-wien.ac.at [83.161.120.155])
	(authenticated bits=0)
	by sslmail1.wu-wien.ac.at (8.13.3/8.13.1) with ESMTP id jBSI9Y6G038325
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO)
	for <joshua86@example.net>; Wed, 28 Dec 2005 19:09:35 +0100 (CET)
	(envelope-from joshua86@example.net)
Message-ID: <joshua86@example.net>
Date: Wed, 28 Dec 2005 19:09:30 +0100
From: "Rony G. Flatscher" <joshua86@example.net>
User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Bean Scripting Framework users <joshua86@example.net>
Subject: Re: jython problem
References: <joshua86@example.net>
In-Reply-To: <joshua86@example.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-WU-wumi-status: clean v4.4.00/v4650 sslmail1 wu 88cdeacd7ead4164d662aa2d8364adff
X-Virus-Checked: Checked by ClamAV on apache.org
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N

Hi Johannes,

not being too familiar with Python/Jython, the following sample program 
*does* run with the BSF:

-------------------- cut here ------------------
"""\
A silly little calculator implemented in JPython using
Java components for the UI.
"""

import java
from java import awt

def exit(e): java.lang.System.exit(0)

def getField (f):
    t = f.getText ()
    if t == '':
        return 0
    else:
        return java.lang.Integer.parseInt (t)

def doMath (e):
    n1 = getField (f1)
    n2 = getField (f2)
    sum.setText (repr (n1 + n2))
    diff.setText (repr (n1 - n2))
    prod.setText (repr (n1 * n2))
    quo.setText (repr (n1 / n2))

f = awt.Frame ('BSH Calculator (jpython)', windowClosing=exit)

f1 = awt.TextField (20, actionPerformed=doMath)
f2 = awt.TextField (20, textValueChanged=doMath)

p = awt.Panel ()
p.setLayout (awt.GridLayout (2, 2))
p.add (awt.Label ('Enter Operand'))
p.add (f1)
p.add (awt.Label ('Enter Operand'))
p.add (f2)

f.add ('North', p)

f.add ("Center", awt.Label ('Results:'))

p = awt.Panel ()
p.setLayout (awt.GridLayout (4, 2))
p.add (awt.Label ('Sum'))
sum = awt.TextField (20)
p.add (sum)
p.add (awt.Label ('Difference'))
diff = awt.TextField (20)
p.add (diff)
p.add (awt.Label ('Product'))
prod = awt.TextField (20)
p.add (prod)
p.add (awt.Label ('Quotient'))
quo = awt.TextField (20)
p.add (quo)
f.add ('South', p)

f.pack ()
f.show ()
f.toFront ()
-------------------- cut here ------------------

It runs without a hitch. (This is running with the latest sources of BSF 
from the repository.)

Maybe it serves you as a jump start example?

HTH,

---rony



---------------------------------------------------------------------
To unsubscribe, e-mail: joshua86@example.net
For additional commands, e-mail: joshua86@example.net



{'source': 'Apache Software Foundation Public Mail Archives'}