0

I have a class that is written in Java.
Can it be used in Python so i dont have to rewrite it?

8
  • 3
    Wait, wat? You'll have to clarify... extensively. Run Python on a JVM (in that case, Jython is the answer)? Generate Java code from Python? [enter another interpretation here]?
    – user395760
    Commented Dec 10, 2010 at 22:16
  • 2
    I have a class that is written in Java. Can it be used in Python so i dont have to rewrite it?
    – user538442
    Commented Dec 10, 2010 at 22:17
  • Thanks. So Jython is indeed the answer.
    – user395760
    Commented Dec 10, 2010 at 22:20
  • Thanks! Seems to do exactly what I need.
    – user538442
    Commented Dec 10, 2010 at 22:23
  • 3
    Ummm ... if the class is 1800 lines long, may be it needs to be rewritten.
    – Stephen C
    Commented Dec 10, 2010 at 22:49

2 Answers 2

13

JYthon is a python implementation in java , you should check it out

www.jython.org

1
  • Yes, this is interesting. I will have to investigate this
    – user538442
    Commented Dec 10, 2010 at 22:20
3

See this: http://jpype.sourceforge.net/

Might not be worth the trouble, though..

3
  • I have a class that is already written in Java. I need to use python for this particular project. It would be a pain to have to rewrite it in Python. This is also a very interesting response. I need to investigate this. Seems like there might be quite a bit of overhead associated with it though
    – user538442
    Commented Dec 10, 2010 at 22:21
  • What i meant by 'not be worth the trouble' is that rewriting the class just might be the simplest solution. Keep in mind the way you python code should be deployed. If you use your Java class, it requires you to install and deploy at least JRE Commented Dec 10, 2010 at 22:29
  • True, that is a good point. It would be rather time consuming to rewrite it though and debug it. This is definitely interesting though. i am going to explore this and Jython before I begin anything
    – user538442
    Commented Dec 10, 2010 at 22:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.