aspose file tools*
The moose likes Jython/Python and the fly likes how to wrap python around java using jython Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "how to wrap python around java using jython" Watch "how to wrap python around java using jython" New topic
Author

how to wrap python around java using jython

Sony Chau
Greenhorn

Joined: May 23, 2012
Posts: 4
I have been assigned a task to convert a java standalone application to python web application.Recoding the entire module in python language would take a lot of time and effort.Hence I was adviced to do a quick wrap up of python and get the code working (Jython is Python wrap for JAVA )..Could any one guide me how to get started as I am new to Python as well as Jython?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hmmm. I'm not sure Jython helps you at all here. Jython is a Python interpreter written in Java; it lets you run Python code inside a Java application. What you want to do is quite the opposite, if I understand you correctly: you want a Python application -- the web container -- to run some Java code. If the Java code just accepts command-line arguments and spits out some output in a file or on standard output, this would be fairly simple -- you could use use call from the Python subprocess module -- but if the Java program has a GUI, it's going to need to be substantially modified for you to be able to make this work.


[Jess in Action][AskingGoodQuestions]
Sony Chau
Greenhorn

Joined: May 23, 2012
Posts: 4
Thank you for the reply.You've understood my requirement correctly.My application has made use of java swing GUI.You have mentioned it would require substantial modifications to make the application work.Could you throw some light as to what kind of modifications are required and how do I proceed.Currently java swing GUI makes use of lot of JTables and JTabbedPanes.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, sadly, the whole GUI will have to be removed; you'll have to write a new GUI which works via HTML and Javascript. You may write it in Python or in Java, but I imagine Python would be easier here, using whatever GUI framework the Python web container is set up to use. The rest of the application -- the non-GUI parts -- may have to be modified to deal with multiple simultaneous users. For example, if part of the application writes to a file with a hard-coded name and path, then that code will need to change.
 
 
subject: how to wrap python around java using jython