# HG changeset patch
# User Paul Boddie You can run Java classes by finding one with a main method and executing
it. Here's a comparison of a freshly prepared Java class being run in Python
and in a Java virtual machine respectively: cd tests/ javac Value.java runclass.py Value v.getValue() correct: 123 java Value v.getValue() correct: 123 It can be more interesting to get into Python's interactive mode and then
start playing around with Java classes: Python 2.2.2 (#2, Jan 21 2005, 16:16:57) import javaclass.classhook from __this__ import Value dir() ['Value', '__builtins__', '__doc__', '__name__',
-'javaclass'] dir(Value) ['__class__', '__delattr__', '__dict__', '__doc__',
+
-v.getValue() correct: 456
-v.isPositive() correct: 1
-v.isPositive() correct: 0
-v.compare(-790) correct: -1
-v.compare(-788) correct: 1
-v.compare(-789) correct: 0
-v.getValue() == v2.getValue() correct: 0
-v2.add(-123) correct: 0
-v2.getValue() correct: 255
-v.getValue() correct: 456
-v.isPositive() correct: true
-v.isPositive() correct: false
-v.compare(-790) correct: -1
-v.compare(-788) correct: 1
-v.compare(-789) correct: 0
-v.getValue() == v2.getValue() correct: false
-v2.add(-123) correct: 0
-v2.getValue() correct: 255cd tests/
+javac Value.java
+runclass.py Value
+v.getValue() correct: 123
+v.getValue() correct: 456
+v.isPositive() correct: 1
+v.isPositive() correct: 0
+v.compare(-790) correct: -1
+v.compare(-788) correct: 1
+v.compare(-789) correct: 0
+v.getValue() == v2.getValue() correct: 0
+v2.add(-123) correct: 0
+v2.getValue() correct: 255
+java Value
+v.getValue() correct: 123
+v.getValue() correct: 456
+v.isPositive() correct: true
+v.isPositive() correct: false
+v.compare(-790) correct: -1
+v.compare(-788) correct: 1
+v.compare(-789) correct: 0
+v.getValue() == v2.getValue() correct: false
+v2.add(-123) correct: 0
+v2.getValue() correct: 255
The Slightly More Credible Example
-[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
-Type "help", "copyright", "credits" or "license" for more information.Python 2.2.2 (#2, Jan 21 2005, 16:16:57)
+[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
+Type "help", "copyright", "credits" or "license" for more information.
+import javaclass.classhook
+from __this__ import Value
+dir()
+['Value', '__builtins__', '__doc__', '__name__',
+'javaclass']
+dir(Value)
+['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__init______I_', '__module__',
'__new__', '__reduce__', '__repr__', '__setattr__', '__str__', '__weakref__',
'add', 'add____I_', 'compare', 'compare____I_', 'getClass', 'getClass___',
'getValue', 'getValue___', 'isPositive', 'isPositive___', 'main',
'main___java__lang__String_array_', 'newValue', 'newValue___', 'setValue',
-'setValue____I_']
v = Value(20050121)
- -v.getValue()
+'setValue____I_'] +v = Value(20050121)+
v.getValue()+
20050121+
v.setValue(20050401)+
v.getValue()+
20050401-
20050121
- -v.setValue(20050401)
+v.getValue()
- -20050401
+The javaclass software is distributed under the terms of the GNU Lesser
+General Public Licence (LGPL). See the file COPYING.txt
in the
+docs
directory within the source code distribution.