[Q] Build java files for android platform - Android Q&A, Help & Troubleshooting

Hi,
I'm new to android developement. To make it short. Our project needs to be ported for android. It has some java and C code. We run this java as applet using Oracle JRE in linux systems and using firefox browser.
Now it needs to be done on android and browser. Android doesnot support JRE. Hence i downloaded eclipse, ADT plugin. Added my java files, external JRE library and compiled it. Got the apk and classes.dex.
Now my question here is i'm not able to proceed further. How to execute the same as in JRE before. I'm totally confused. Running the apk in emulator/android mobile only runs the activity.java code. Say i'm printing hello world in that(i dont need that but still i have wrote it as my first program).
I dont know how to execute my other java files(which will run as java applet before in linux systems). I'm stuck here since i have not worked on android.
This would be the first step in to my porting.
Also the easy solution would be to run the applet.jar i have directly on android similar to linux jre. Is it possible.?
Any sort of help would be great. Thanks.

Related

trying to set up eclipse and sdk

im trying to learn how to make apps for my phone andim trying to install the sdk and al the tools i need. i installed java jdk i sved it in c:\programfiles.
i then downloaded the sdk zip and unzipped it to c: i then doanloaded eclipse and unzipped it to my desktop. everytime i try to run it it says " a JRE or JDK mist be available in order to run. no java VM was found after searching c:\users\guest\deskpto\eclipse-jee-etc\eclipse\jre\bin\javaw.exe in your path. also how to i update my sdk ...any help is greatly appreciated thank you
I think your post fits better in the "Android Development" forums, since this forum is aimed at making roms. You'll get more response there.
Thread moved to Android section.
Make sure your Java is up to date, check out the java website and install JDK

Android SDK Setup - Java is not found in your PATH.

Hi,
I am new to Android. I have downloaded and installed every necessary component in order to start working with Android. The issue I am having is that in Command Prompt, anything I type in related to the Android SDK (for example: adb, or even just android) comes back with "Java was not found in your path". Now, I have changed all my PATH variables under "User" to the EXACT locations of where these folders are, but no dice. It keeps telling me to go and edit my PATH variables. Even running SDK Setup, gives me the same error, and tells me to add where Java was found (even though I have!).
I am starting to get really fed up with this, because Eclipse can't find the "jre" folder inside the Java JDK, either (that is, of course, until I copy the entire jre folder inside of the eclipse folder, or put eclipse inside of the JDK folder)...
I just know it shouldn't have to be this tedious to set everything up and I would really appreciate it if someone can help with this
I am running Java JDK 1.6.0_21 (x64), Eclipse Helios (3.6) IDE for Java EE Dev., Android SDK Revision 6, all on Windows 7 Ultimate x64.
Something to note: I have not encountered any problems with Eclipse Helios and the ADT plugin as stated on the Android Developers website. I can use Eclipse and the SDK to create and run the"Hello, Android!" application on the emulators without issues. I just want to be able to run everything from the command prompt, too. Now, if I can only get my phone to be recognized after I get this resolved.
I also need this for rooting and unlocking the phone.
Bazz44 said:
Hi,
I just know it shouldn't have to be this tedious to set everything up and I would really appreciate it if someone can help with this
I am running Java JDK 1.6.0_21 (x64), Eclipse Helios (3.6) IDE for Java EE Dev., Android SDK Revision 6, all on Windows 7 Ultimate x64.
Click to expand...
Click to collapse
In the SDK tools folder go to libs and edit find_java.bat.
Change all instances of %PROGRAMFILES% to %PROGRAMFILES(X86)% .
I had to do this for my SDK.
Your java will probably still resides in c:\program files (x86)\java or the likes.
To test if it works open DDMS.bat(May need to open twice).
I ran "ddms.bat" before changing the "find_java.bat", and it just came up that it could not find the path > checking if it is installed elsewhere. I did what you suggested (I found three instances of where I needed to add the (x86)), ran "ddms.bat", and got the same error. However, this time it also opened the Dalvik Debug Monitor. Eclipse still won't run without its own copy of the "jre" folder from the JDK at the same folder level as the "eclipse.exe"...
any luck with this? I'm also having same trouble in Win7x64
Gonna give in otherwise n reboot my ubuntu system see if thats any easier
i know i can't use OpenJDK or something so ill have to swap that but fingers crossed
=]
Solution
Install any JRE Java, Copy the java folder at program files/Java/jre6 Paste it inside MOTODEV´s folder program files/Motorola/MOTODEV Studio for Android 1.2/ and rename it to jre
Done
Edited the eclipse .ini works a treat now wi java x64...
time to whip out the olde java books from college an see if any of it comes back to me
Is it possible to install the android sdk platforms & extras offline manually, my only net atm is my desire tethered, unlimited data but I don't wanna push my luck
I'm not sure if it may be related or not but according to the android dev page, you should be using eclipse 3.5 because they have been having problems with 3.6
May or may not be related but worth a shot.
I'm not sure if it may be related or not but according to the android dev page, you should be using eclipse 3.5 because they have been having problems with 3.6
May or may not be related but worth a shot.
i need help http://forum.xda-developers.com/showthread.php?p=24028502#post24028502
Please use the Q&A Forum for questions &
Read the Forum Rules Ref Posting
Moving to Q&A
Make nu system path
Try making new system path named PATH (all caps). its an issue with Win7 64. Hope it helps. and yes Installing the Android sdk is a giant head****. I have it all put as fare as the link to abandroid put it doesn't make plug-in available in the plug-in list. I'm at a loss...
As i said, hope it works.
Having just had this issue myself on a new install of eclipse, the sdk and adt, here's what finally helped me: making sure the java\sdk1.6.x.x\bin directorywas in front of the windows\sys32 directory in the PATH statement of the environmental variables.
I did already add the JAVA_HOME and such, but the above was the step that finally allowed me to finish the setup.
Fix for Win7 64bit and Android SDK/Java install
MacDegger said:
Having just had this issue myself on a new install of eclipse, the sdk and adt, here's what finally helped me: making sure the java\sdk1.6.x.x\bin directorywas in front of the windows\sys32 directory in the PATH statement of the environmental variables.
I did already add the JAVA_HOME and such, but the above was the step that finally allowed me to finish the setup.
Click to expand...
Click to collapse
I had to finally use JAVA_HOME C:/PROGRAM FILES/JAVA/JDK1.7.0_05 That finally allowed me to instal the Android SDK
best answer
rowdyvc said:
I had to finally use JAVA_HOME C:/PROGRAM FILES/JAVA/JDK1.7.0_05 That finally allowed me to instal the Android SDK
Click to expand...
Click to collapse
Thank you you solve my prob man

[Q] How to install Java or plugins in Firefox of ICS?

Dear all,
Some websites require to use Firefox and install JAVA or plugins to play movies. But when I use Chrome to open these webs and click on the guided link to download JAVA, it told me that there is no suitable version yet.
When I use Firefox to open these webs, it said there are no plugins, and didn't tell me what plugins.
But I can open these movies on webs using android 3.1 or lower.
So, is it because ICS 4.0.3 hasn't supported to open webs which require JAVA or there are other ways to open these movies?
thank you very much for your reply.
Oracle doesn't make plug-in for Android but you may use Adobe Flash Player. But it's strange
I've already installed Adobe flash player 11 before but it's no use.
Actually they require JAVA runtime or plugins or something like that.
Android has no Java support. In order to use a Java plugin, the installation of Java se runtime for arm CPU would be required (it worked like a charm on my old Nokia n900 debian based) but there would be no way to use the Java vm into the dalvik vm.
The only way (if your phone is a dual core, though it'd too slow) is running Java applet into an Ubuntu chrooted environment. In that case, it would be strongly suggestable to download the latest version of Java se from oracle site, which has jit and is very fast in comparison to the version you can find on current Ubuntu img.
Then, you'll just have to unpack it and put it somewhere in Ubuntu chrooted fs and make a symbolic link in order to jar to be launched via that Java se version. Besides, check inside Firefox configuration (always the chrooted one) and manually set the plugin path, though it could use the old version.
So you'll get a fully functional Java vm in android
wow, it's complicated. So it means that I have to install 'ubuntu installer' (the same as 'linux installer' in Play Market, is it right? ) and then install firefox with plugins to use, does it?
If do it this way, my phone will run 2 environments (Android and linux) at the same time and it'll become too slow then. I think my galaxy s2 with CPU 1.2ghz, ram 1g is not enough to do this . Should wait till Android supports JAVA then
thank you for your help, lucaoldb!
You are welcome
It is easier than it looks. Anyway, the Ubuntu chrooted img has already Java support, though it is a slower version. You can test it and see if fits to your needs. If you want an improved performance, you can follow the way I suggested above.
---------- Post added at 02:09 PM ---------- Previous post was at 02:03 PM ----------
By the way, your hardware is ok and Java se support in android will not very likely be avalaible in next years, because Oracle sued Google people for copyright violation and the whole thing is not yet over...
lucaoldb said:
Android has no Java support. In order to use a Java plugin, the installation of Java se runtime for arm CPU would be required (it worked like a charm on my old Nokia n900 debian based) but there would be no way to use the Java vm into the dalvik vm.
The only way (if your phone is a dual core, though it'd too slow) is running Java applet into an Ubuntu chrooted environment. In that case, it would be strongly suggestable to download the latest version of Java se from oracle site, which has jit and is very fast in comparison to the version you can find on current Ubuntu img.
Then, you'll just have to unpack it and put it somewhere in Ubuntu chrooted fs and make a symbolic link in order to jar to be launched via that Java se version. Besides, check inside Firefox configuration (always the chrooted one) and manually set the plugin path, though it could use the old version.
So you'll get a fully functional Java vm in android
Click to expand...
Click to collapse
I downloaded Java for ARM from Oracle site; these are the libs provided:
Code:
[email protected]:~/Downloads/ejre1.6.0_32/lib/arm# ls
client libhprof.so libjawt.so libnio.so
headless libinstrument.so libJdbcOdbc.so libnpt.so
jli libioser12.so libjdwp.so librmi.so
jvm.cfg libj2gss.so libjpeg.so libunpack.so
libawt.so libj2pcsc.so libjsig.so libverify.so
libcmm.so libj2pkcs11.so libjsound.so libzip.so
libdcpr.so libjaas_unix.so libmanagement.so native_threads
libdt_socket.so libjava_crw_demo.so libmlib_image.so
libfontmanager.so libjava.so libnet.so
I cannot find libjavaplugin_oji.so or libnpjp2.so to create the symbolic link for Firefox.
How can I do?
Regards
EDIT:
Solved, I downloaded headless version of JAVA SE instead of headful version:
ejre-1_6_0_32-fcs-b05-linux-arm-vfp-eabi-headful-05_apr_2012.tar.gz
ejre-1_6_0_32-fcs-b05-linux-arm-vfp-eabi-headless-05_apr_2012.tar.gz
in headful version the file libnpjp2.so is present.

Running compiled Java code

Hi.
I want to know if it's possible to run compiled Java code (through the CLI) on my Android (4.0, HTC Sensation XE). I'll be writing and compiling the code on my laptop. The cli programs that I want to write are fairly simple (using java base classes, networking), no graphical interfaces or anything that requires elevated privileges.
My phone is not rooted.
There is no JVM on android, so you cannot directly run Java apps compiled for desktop. All android apps are compiled into dalvik bytecode.
knutson said:
There is no JVM on android, so you cannot directly run Java apps compiled for desktop. All android apps are compiled into dalvik bytecode.
Click to expand...
Click to collapse
So can I get the dalvik VM (with the compiler) on windows/linux ?
From wikipedia I've read that there's a tool called dx that can convert .class files to .dex (but not any .class files can be converted).
Mayhem00 said:
So can I get the dalvik VM (with the compiler) on windows/linux ?
From wikipedia I've read that there's a tool called dx that can convert .class files to .dex (but not any .class files can be converted).
Click to expand...
Click to collapse
It is possible to install Android to VirtualBox and use it to run Android apps (much faster than emulator from Android SDK).
knutson said:
It is possible to install Android to VirtualBox and use it to run Android apps (much faster than emulator from Android SDK).
Click to expand...
Click to collapse
But I want to be able to run short Java programs I make on my phone .

[Q] Trying to compile AOSPA : java 6 problem

Hi,
I'm following this tutorial http://forum.xda-developers.com/showthread.php?t=1863547 in order to be able to compile PA for my Nexus 4.
I get stuck at java 6 installation : as I'm using a Debian (jessie) as my daily OS, and trying to learn java, I already had it with eclipse and the command "java -version" showed me version 1.7 and openjdk 7.
So I anyway tried to purge java, this of course removed eclipse, and the next step in the tutorial explained how to install Oracle JDK. But I wanted to keep using OpenJDK so I just did a basic install of openjdk-6 with aptitude.
At this point "java -version" shows me 1.6, but... Installing Eclipse and its dependencies make java 1.7 and openjdk-7 come back...
There must be an easy way to solve this ?
Thanks!
PS : As you probably understood I'm using debian daily but I'm not yet a linux geek ^^

Categories

Resources