I have to implement one web2py application which has to access java code (which has code to connect to the remote machine) but not sure whether we can do it in web2py or not.My PC has Java 1.6, Python2.7 ,web2py ,eclipse installed.
Use case is :
I have created one button in web2py application and upon clicking the button, it should instantiate the java object and invoke particular method of that java object which will further connect to the remote machine.
Doubts are:
Can we deploy that particular java class to web2py server so web2py application can easily access it?
Is it possible to import that class from python code?
How to instantiate java object from python code?
And how to invoke java method from python code?
Regards, Piks
I would consider looking into webservices. If you could expose url from java, that will route to a method/function of java where logic is performed and it returns json object. While in web2py urllib2 you can make a request and decode that json into native python dictionary. The clue is that you would have to expose all the methods of objects and pass the object back and forth as json. Do not be scared in most programming lanugages objects are just hash_arrays/dictionaries with some special qualities. So if you can serialize and deserialize the object and expose apriopriate urls you will be fine.
Also there is implementation of web2py in jython. But then the entire stack will be in JVM and i may be more complex to work with.