• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting Python to Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic