• 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

A typical Question

 
Greenhorn
Posts: 25
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider that I have developped a small desktop application in java swing using eclipse. I have exported the project to a jar file. when I right click and run it with java it operates perfectly. Using JAR-TO-EXE tool I have converted it to exe file as well which is also working properly. Now my question is that can I use that in my mobile? I'm using Samsung galaxy s advance...which has Android v2.3 OS. Does it support .exe or .jar file? If not then is there any way to run the code in my phone as well? I have the source code and using eclipse. Does eclipse have any Add-ons to export the code in such a format that works in my samsung phone?

Any comments or suggestion is appriciated.
 
author & internet detective
Posts: 41907
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This article says Android doesn't have a JDK and suggests using an emulator.

In general, just an "exe" oversimplies things. An exe is meant to run on just one operating system. You can't take a Windows exe and run it on Linux and shouldn't expect to on Android. Also, you might be calling "non-mobile" APIs if you didn't develop this app with a phone in mind.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you should not expect the application to work. Android does not support Swing, it has its own UI libraries.

Android would let you use a JAR as a library in your Android app, but the app itself must not be a JAR. So your strategy would be to isolate the UI (Swing) from the code, build the rest of the code into a JAR. Create an Android app (Eclipse has as an ADT drop-in), build the UI for the Android app, and add your JAR as a library to the action. What I do is have 3 projects in Eclipse:
1) JAR library which holds as the work/logic
2) Desktop project using Swing (or other UI). Uses the JAR from (1) as a resource
3) Android project with its own UI. Uses the JAR from (1) as a resource

You have to be careful: Android does not have a full Java implementation - it has a lot of it but not everything (for example no Swing). So check their API out to see what parts are available. Make sure your JAR doesn't using anything not present or it won't work.

See this instruction for getting the ADT plugin for Eclipse.
 
Koushik Ghosh
Greenhorn
Posts: 25
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks man... that really helps
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic