Is it possible to run java application on android through openjdk - android

Disambiguation first: question is not about developing or compiling with openjdk code that would be run on dalvik in production. It is about using oracle runtime on android environment.
I'm using java for running small desktop utility application. I have no experience in Android and iOS development and I'm curious to which extent my classic java skills may be transferred to the mobile field.
I've googled couple of methods for running java application on iOS embedding runtime inside the application package. Android has its own partially incompatible and slow java virtual machine. It still is better than nothing, but I'm curious if it is possible to run application on genuine hotspot(openjdk) virtual machine. Android as well as iOS have the ability to run native code. May this ability be exploited to use third-party (non dalvik) jre on android?
I'm not interested on google play market so restrictions from it, if there are any, may not be taken into account.
Rooting is also possible since I'm going to write tools for myself. I would prefer methods that would be easy for installing. Like putting some package files and editing couple of options. And not build my own android distribution like CyanogenMod.

Without rooting the device, I don't think there is a way to do it.

Apparently, see http://openjdk.java.net/projects/mobile/android.html
The instructions are slightly out of date, I managed to do some hacking and get it to build though. Not sure if it runs yet

Related

Port .NET dll to different platforms

I have a dll based on .NET 2.0 with full source code access.
So I can build it in VS2010.
I need to port this to Android/iOS/MacOS.
As a result I expect some equivalent of dll for each platform.
So another programmer can link (doesn't matter how) this equivalent to his own project at one of that targeted platform.
For example I ran MonoDevelop on Mac and don't see how I can build my .NET project and to receive such equivalent of dll.
So I need help to find solution and understand what to do to receive requierd result.
There are CLI implementations, primarily Mono, that work on both iOS and droid. The simplest tools here are MonoTouch and Mono for Android, both available from Xamarin. With these tools, you can build and test your dll targetting the relevant frameworks. Another programmer, again using the MonoTouch or Mono for Android tools, can reference those dlls, and build their application, with all the tools necessary to package and deploy (side-loading or via, say, the device's store) an application using that library. This deployment will typically also include all the runtime/framework pieces needed by the application.
MonoTouch makes use of the MonoDevelop IDE, so will be familiar to you as a MonoDevelop user. Mono for Android can do that (i.e. be hosted inside MonoDevelop), but can also be used inside Visual Studio.
Running .NET code requires a .NET runtime to be installed. Neither Android nor iOS devices come with such a runtime preinstalled.
In theory, you could install the Mono Runtime (a open-source .NET alternative) on an Android device or a jailbroken iPhone/iPad. However, as I understand it, you're looking for a way to create a library to give developers, so this isn't a good solution.
However, what could work is creating a library with MonoTouch. MonoTouch compiles your .NET code to a binary that iOS devices can use - regardless if they're jailbroken or not, without needing a runtime installed.
If you follow best practices, you might port your library successfully, such as
http://sharpsnmplib.codeplex.com/discussions/390251
However, it purely depends on the characteristics of your library, which you does not mention yet.

Developing native C applications android without the NDK?

OK this is a strange one:
Is there a way someone can develop native C applications or libraries for Android without using the Android NDK?
What was happening before the NDK was released?
(It's not there for too long, I think it was released only one or two years ago).
Apparently, you can -- a friend of mine is a real Android guru and he managed to build a GCC-based native toolchain entirely by hand. He also fixed some missing parts in Android's libc. The main idea is the following: GCC has builtin support for the arm-elf-linux target, so with an appropriate build script, you can configure it to build for Android. However, you have to root the phone to run the resulting binaries. One even cooler thing is that because GCC is a self-hosting compiler, with the arm-linux-elf toolchain, you can recompile GCC once again and have the toolchain on the phone itself.
Before the NDK was released, the only officially supported way of developing Android applications was to use the Android SDK and writing your applications in Java.
As others have mentioned, it's possible to cross-compile some applications as completely stand-alone and run them on a rooted phone. The downsides of this should be obvious: very few people will be able to run your application (they also need to be root, plus you won't be able to get your application up on the Play store); and you might even run into compatibility problems yourself across different devices e.g. if you rely on dynamic linking against various libraries (which you might need to do in order to keep the size of the binary down).
TL;DR: it's possible, but severly limited, and not recommended.
You can compile your C code with an Android-compatible toolchain (such as CodeSourcery) and run it on a non-rooted phone, from its command line (for example through an SSH connection like SSHDroid).

Build Android app to run in JRE

I have seen questions and topics in google referencing running JRE apps in the android environment, but I am actually thinking about the reverse.
I understand Android runs on a different runtime engine than the standard JRE.
Is it possible to build an app to run on android, but also build and run the same app in the JRE on a desktop?
I assume there would be restrictions on API usage, I was just thinking about the possibility to distribute a simple app that could be useful on both the device and the desktop.
I think the bigger problem here is going to be accessing the Android API and environment on your desktop. Do you have a plan for that?
If you have the Android environment running on your desktop then there shouldn't be any problem running your app there.
This answer offers an alternative suggestion.
Short answer: your desktop and Android app can share a large portion of code, but you aren't going to be able to run Android-specific code on the desktop.

can native only code run on android as standalone application

We want to migrate a huge complex native program to Android system ,running it as a background service accepting command sent from Java Program using JNI along with IPC. However, the Android NDK state following words:
Please note that the NDK does not enable you to develop native-only applications. Android's primary runtime remains the Dalvik virtual machine.
Does that mean we have no way to run an standalone native-only application on Android as a background service? The native code can only exist in the form of library that will be loaded to the virtual machine through JNI?
The NDK itself is only for creating libraries, though if you do some web searching you will find that there are at least two sets of wrapper scripts or instructions for (ab)using its toolchain to make standalone executables linked against android's bionic libc (something you would not get from a non-android arm toolchain).
The google folks do not encourage people to do this. Unfortunately, their vision of android only includes java applications, with optional native libraries in support - it does not include any "stable" means of installing or launching a native executable, in the sense that they warn the methods you might be able to use today may not continue to work in new versions. This is really too bad, as it means giving up a lot of the general-purpose-computer potential of the device.
Well, it can be done. But to be honest i've never tried it using the NDK, but i've managed to create native applications using the toolchains provided with the android source code.
Your phone (incase your talking about phones) should be rooted.

.JAR + Android?

I just purchased an Archos 5 and I'm wondering if it is possible to put a .JAR file on it and use it as an application. I read somewhere that it is possible but saw somewhere else that it wasn't. If it is possible, is there anything I have to do differently? Or do I just run it like I would on my computer?
Android devices run Android applications, not ordinary Java applications, and the ARCHOS 5 is no exception. While Android applications are written in Java, an ordinary Java desktop application uses a different GUI framework than Android offers.
As said by CommonsWare, although Android apps are written in Java you can't actually run Java code(s) on Android devices sinces Android actually has the Dalvick Virtual Machine as compared to the Java Virtual Machine (which runs the Java Bytecode)
If you still plan to use the logic of your jar file and run it on your device, you may reference it in an android app and use the feature(s) from it.
But be awared, that this mostly depends on what your jar file actually does and how it is packed. You may need to, otherwise, repack it to suit if for using in it Android apps.
Bottom line is, however, you can't run the jar files directly on the device!

Categories

Resources