Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting Python to Java

 
J Hicks
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I had hoped to find a great place to get information on converting Python to Java, either using Jython or some other program.

I dont know Java. I wrote this script in python and I'm wanting to be able to make it work for Android/iOS. There doesnt seem to be an easy way to do this without distributing the python file directly (using sl4a). I use these imports:

import sys
import csv
import re
import json
import time
import string
import random
import urllib
import urllib2

Does anyone have advice on where to start etc? This is essentially a farming robot that automates farming in a game we play online. If anyone wants to see the code or can translate to Java easily please let me know. I have started the Java translation but fear I'm getting in way over my head with Java. Thanks guys take care.
 
Joe Ess
Bartender
Pie
Posts: 9259
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.

J Hicks wrote: I wrote this script in python and I'm wanting to be able to make it work for Android/iOS.


Android and iOS are very different ecosystems. Programming in iOS is usually done with Objective-C. Android programmers use a customized version of Java. If you want to target both OS's, you'll either have to write two versions of your app or use a cross-platform development tool like Appcelerator.
As for translating a Python program to Java, they use very different programming paradigms so there will not be a 1:1 match for functionality (especially given your mobile requirement, which adds another API in the mix). I honestly don't think you can hope to translate the app without getting knowledgeable about Java and Android.
 
chris webster
Bartender
Posts: 2407
32
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible to run Python on Android, via the Scripting Layer for Android (SL4A). Not sure which libraries etc are supported, but you could have a look at getting your Python app to run with SL4A e.g. using the Android emulator.

Of course, this doesn't help you at all with iOS.

Edit: Duh - just saw that you'd already looked at SL4A!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic