• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A typical Question

 
Koushik Ghosh
Greenhorn
Posts: 25
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34214
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks man... that really helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic