#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    1
    Rep Power
    0

    Question need to convert python code to java


    I have a code in python.As i have to my coding in Java,and infact started other part of the coding in java. Now i need to change certain code written in python to Java.
    Can anyone suggest me a wayout.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    73
    Rep Power
    11
    Would it not benefit you to switch to coding in Jython? I'm not sure, I;ve only read little bits on Python/Jython.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    As Rayman says, it is possible to mix python and Java code with Jython. Jython is the Python language implemented in Java, so you can call Java code from Jython, and compile Jython classes into object that can be accessed from Java.

    There are disadvantages to this - Jython only implements the version 2.1 features of Python, so no list comprehensions or generators. Not all the Python libraries are available either, but since you have all the Java libraries available that is not a big issue.

    Alternatively you could use a Java-Python bridge such as Jpype which allows you to interface Python and Java code.

    If neither of these appeals, you can always recode the Python toJava or the Java to Python. Converting Java to Python is easier IMHO, since there are few language structures in Java that do not have an equivalent in Python, but Python has many features that would be hard to convert to Java.

    Dave - The Developers' Coach.
  6. #4
  7. A wanna-be guru of some sort
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2004
    Location
    Either online or offline
    Posts
    625
    Rep Power
    20
    Why don't you post some or all of your code so people can estimate whether it can be (which probbaly can) and with how much trouble converted to Java?

IMN logo majestic logo threadwatch logo seochat tools logo