import pava


# Tell pava where it can find Java user-defined classes
pava.set_classpath(['c:/Users/laffr/PycharmProjects/pava/pava'])

try:
    import java
    class Out(object):
        def println(self, s):
            print s
    java.lang.System.out = Out()
except ImportError:
    pass


# Load a Java class and call a static method on it from Python

import classfiles
classfiles.HelloWorld.main()


import os
import pava


# Tell pava where it can find Java user-defined classes
print '1. Loading Java...'
pava.set_classpath([os.path.dirname(__file__)])

try:
    import java
    class Out(object):
        def println(self, s):
            print s
    java.lang.System.out = Out()
except ImportError:
    pass

#
# Load the "HelloWorld" Java class and call the static "main" method on it directly from Python
#
# HelloWorld.class gets compiled to Python bytecodes as follows:
#
# Python Bytecodes generated by Pava        Original Java bytecodes in HelloWorld.class
# ----------------------------------------------------------------------------------------------------------------------
#  0 LOAD_GLOBAL    0 java            ### 0 getstatic ('java/lang/System', 'Ljava/io/PrintStream;', 'out')
#  3 LOAD_ATTR      1 lang
#  6 LOAD_ATTR      2 System
#  9 LOAD_ATTR      3 out
# 12 LOAD_ATTR      4 println
# 15 LOAD_CONST     1 u'Hello World!' ### 3 ldc (u'Hello World!',)
# 18 CALL_FUNCTION  1                 ### 5 invokevirtual ('java/io/PrintStream', 'println', '(Ljava/lang/String;)V', 1)
# 21 POP_TOP
# 22 LOAD_CONST    2 0                ### 8 return ()
# 25 RETURN_VALUE
# ---------------------------------------------------------------------------------------------------------------------
#

print '2. Import the Python module that contains the transpiled HelloWorld:'
import classfiles

print '3. Call HelloWorld.main:'
classfiles.HelloWorld.main()

print '4. Done.'

Make the classpath relative, not absolute and add some steps.
Make the classpath relative, not absolute and add some steps.
