Running java programs on android

Is it possible to execute Java programs designed for desktop on Android?

Prior to the emergence of Android, there were Java applications designed for mobile devices that gained popularity. According to www.java.com, KVM serves as the mobile device virtual machine equivalent of JVM (Java virtual machine).

Can you run ‘normal’ Java programs on Android?

Is it feasible to run a computer Java program on an Android device? If so, how can I do it? I have a basic knowledge of Java meant for computers.

Although Android-flavored Java has the same syntax and semantics as typical Java, it cannot run on the conventional Java virtual machine since Google has its own VM for Android phones with different byte code format. Moreover, Google has its own implementation of important elements, such as HashMap and ArrayList, as well as other libraries, but it does not have access to Oracle’s java standard library. Additionally, Google’s library does not include the swing package.

There are several methods to run Java apps on Android, and one convenient option is using a specialized app such as Java Emulators.

The preferred Android Java emulators include JBED, PhoneME, Jblend, and NetMite, listed in order of preference. For unrooted devices, PhoneME is suitable, while the other three applications are recommended for rooted ones.

In case you are referring to the standard Java used on computers as Java Standard Edition (J2SE), which includes programs such as Eclipse and Vuze, it is unlikely that they can be run directly on Android. Unfortunately, there are no known applications or alterations that permit this.

The emulators recommended in previous responses are designed for J2ME, otherwise referred to as MIDP, which supported midlets and was widely used prior to the emergence of android app. These apps are the top choices for mobile devices.

Have you considered utilizing JBED? This software enables the usage of Java applications (.jar files, to be precise) on Android-operated devices. I cannot vouch for it myself as I haven’t used it before.

Which edition of Java is being used in Android J2ME or, Android uses Dalvik. Dalvik is the virtual machine (VM) in Google’s Android operating system. Dalvik is thus an integral part of Android, which is typically used on mobile devices such as mobile phones, tablet computers and netbooks. Before execution, Android applications are converted into the compact …

How You Can Play Minecraft Java Edition PC On ANY

Download: https://www.mcbedrock.com/community/minecraft-mods/pojavlauncher-play-minecraft- java -edition-on- android -devices/HELP ME REACH 1.5 MILLION SUBSCRIB

How to code on Android (C++, Java, Python, Linux on

In this video, we are going see how we can practice coding on a cheap and old android tablet . We can compile and run programs in …

Читайте также:  Стили

How to get Minecraft JAVA Edition UI on Android/IOS

Do you want to have the Java UI on your Android / IOS device? Than make sure to check out this great Resource Pack!-Works for Minecraft Bedrock Edition (Win1

How to run plain old java application on Android

My goal is to execute a Java app on an Android device, which is equipped with Jetty as a servlet container. The app doesn’t involve a UI, and it is a web app that users generally access online. However, I need to run it offline on Android tablets.

Is it feasible to have the equivalent of java -jar . without developing Android applications? I have only discovered resources on creating Android apps, so any details on this matter would be appreciated.

In contrast to a regular JVM, which is used in many systems, Android utilizes a DVM that relies on Apache Harmony. As a result, there is no corresponding feature in Android.

Regardless, recompiling the application is necessary as the DVM solely performs Dalvik-Bytecode, which is produced from regular Java-Bytecode using the tool dx that is included in the Android SDK.

Additionally, what is the purpose of having a Server-Application operating on a tablet device?

Running Java code on Android devices isn’t a straightforward process as these devices don’t have a Java VM. In order to make the code work, one needs to recompile the application and transform it to dex, which is exclusively used by Dalvik VM. The ease of this conversion is determined by the APIs used in the application, as Android only supports a limited number of Java SE APIs.

Test the gnuroot application by using the proot ptrace container on Debian Wheezy. Start by updating and installing openjdk-7-jre through apt-get. Then, access the Java runtime environment by using the path /usr/lib/jvm/java-7-openjdk-armel/jre/bin/java (which has a long path).

Java — Is it possible to run JavaFX applications on iOS, Oracle JavaFX from Java SE supports only OS X (macOS), GNU/Linux and Microsoft Windows. On these platforms, JavaFX applications are typically run on JVM from Java SE or OpenJDK. Android: should work. There is also a JavaFXPorts project, which is an open-source project sponsored by a third-party. …

Android app working in phones but not in tablets

For my final college project, I created an Android app. During development, I utilized an Android phone 4.4 running KitKat as a physical testing device. I also employed multiple smartphone emulators to test my user interface with various Android versions, which all functioned correctly. However, when I attempted to run the app on a tablet or tablet emulator, a Java null pointer exception error occurred, specifically with the button listener (setOnClickListener()) for a fragment’s buttons. As I did not include any code, I suspect the issue may pertain to the initial listener declaration. In summary, the app will work on a phone but not on a tablet, even with an emulator, Null Pointer Exception. Any suggestions would be greatly appreciated. Thank you.

It appears that your question lacks clarity. Presumably, you have distinct layouts for both phone and tab. Therefore, it would be helpful to share your layouts in this scenario.

Читайте также:  How to use class method in python

Assuming that your tab layout has a Button causing a null pointer exception, it may be due to the presence of the attribute android:onClick=»onClick» in its declaration. If your activity has implicitly implemented setOnClickListener for this Button , then setting onClick attribute is unnecessary. However, if your activity lacks an onClick function and your Button refers to an onClick function, then a null pointer exception will occur. I once encountered a similar problem.

After examining my layouts, I found that the /layout-large-port directory contained button fields with incorrect Ids, causing the null pointer exception that I solved. To clarify, my application is designed for portrait mode on smartphones and tablets, and I created the /layout-large-port folder specifically for tablets larger than 7». This folder contains the layouts identified by structure /layout (for smartphones) /layout -large-port).

I will make sure to examine it more closely in the future. Thank you for dedicating your time to this, everyone!

Java — Is there a possibility to run applets on Android or, This is what the Java site www.java.com says: «KVM, the virtual machine for mobile devices, is the counterpart of JVM (Java virtual machine). It is used to run applets and applications written with Java technology on mobile devices. KVM must be installed by the manufacturer.

Is there a possibility to run applets on Android or Blackberry?

According to the website www.java.com, the following statement is made.

Mobile devices use KVM, which is similar to JVM (Java virtual machine), to execute Java-based applets and applications. However, KVM cannot be downloaded or installed by consumers as it is only provided by the device manufacturer.

Android’s virtual machine, DVM (Dalvik Virtual Machine), is customized. Is it comparable to KVM? Moreover, can we enhance DVM by integrating KVM’s features to execute applets on Android? This also applies to BlackBerry, is it feasible?

Despite being used by many organizations, including banks and HMI’s, Java applet still exists. I had plans to purchase a few android tablets for our technicians to utilize in our factory. Unfortunately, there is no applet support available. As a result, I have decided to stick with using my Android tablet as a gaming device for my children.

Is it possible to enhance the programming of DVM to include KVM’s capabilities and enable applets to function on Android?

The need for AWT in applets does not align with what Android offers, resulting in minimal overlapping. Although applets have been obsolete for more than ten years, attempting to customize the Android firmware to incorporate the required classes and execute applets in Android activity does not seem worthwhile.

By default, mobile phones do not support applets. However, customers can opt to purchase a browser that does support it, such as the Cloud browser. To enable Java applets to run on mobile devices without the need for a special browser, we offer a technology to convert existing ones. If your company requires this service, kindly reach out to us through our website, unitedswe.

There are several reasons why Applets cannot run on a BlackBerry device, but the main one is that the AWT classes that Applets rely on are not present on the device. The BlackBerry UI model differs significantly from AWT, and instead utilizes either the MIDP UI model or the BlackBerry model.

Читайте также:  Что это значит javascript

In order to ensure compatibility across mobile platforms, it is advisable to utilize JavaScript for browser-side computing. Regrettably, applets are no longer a viable technology option.

Are there any Android browsers that support loading a, Android still does not support Java applets, nor will it, without major work. The Java in Android isn’t ‘real’ Java — it is a custom written version by Google. Android apps may be written in Java, but they are converted to Dalvik at compile time. As such, it would be nigh on impossible to develop a browser that has compatibility …

Источник

Запускаем консольные Java приложения на Android

Речь пойдёт о проекте-утилитке, который может пригодиться всякому кто изучает Java и не всегда имеет под рукой ПК для просмотра работы примера кода в полевых условиях (как-то — в метро, маршрутке, кафешке и т.д.).

Необходимость создать сие поделище возникла когда я готовился к OCJP-сертификации. После успешного прохождения оной, решил предоставить плоды своих задумок на обозрение уважаемым участникам хабрасообщества.

Ноутбука у меня нет, а запускать примеры кода на смартфоне, сидя на кухне за чашечкой чая, удобно.

Так уж повелось, что бо́льшая часть примеров для обучения обычно приводится именно в формате консольных программ. Замечательный инструмент AIDE позволяет собирать Android-приложение на основе Eclipse-проектов. Возможность, увы, недостаточная для запуска консольных примеров методом копипасты.

Дело за малым — перенаправляем потоки ввода/вывода в UI контролы:

 private static OutputStream mOutputStream = new OutputStream() < @Override public void write(int b) < MainActivity.getInstance().write((byte)b); >>; @Override public void onCreate(Bundle savedInstanceState)

Консольная программа стартует в отдельном потоке из обработчика activity onResume() :

 @Override public void run() < try < // // Здесь запускается консольное приложение // Program.main(new String[0]); >catch (Throwable ex) < // Тут же ловим все исключения setErrorColor(); ex.printStackTrace(); >> 

Здесь же можно задавать аргументы командной строки — старый добрый args . Пример — запуск BankTellerSimulation на 10 секунд:

BankTellerSimulation.main(new String[] < "10" >); 

Поддерживается работа нескольких потоков ( SimpleThreadsTest ):

HorseRace и BankTellerSimulation — примеры более сложных многопоточных приложений (взяты из книги Thinking in Java, 4th Ed by Bruce Eckel).

Ошибки времени выполнения
class FuuuuuuException extends RuntimeException < public FuuuuuuException(String message) < super(message); >> . throw new FuuuuuuException(". TROLLFACE. "); 

Ввод

Напоследок, для полноты возможностей, был добавлен консольный ввод. Пока что мои познания в области пользовательского интерфейса Android не велики. Кое-как впихнуть EditText удалось, но результат не идеален 🙂

Приглашение ввода строки ( ReadingInputTest ):

Функции меню

Exit выключает процесс через System.exit(0) .

Программа «одноразовая». Повторных перезапусков нет (не хотелось возиться с очисткой значений статических полей).

Что делает Clear — большой секрет.

Что не работает

• assert ‘ы Java. Т.е. оператор

исключение java.lang.AssertionError не кинет. Не путать с assert’ами JUnit — с ними всё в порядке!)
• Класс Console .
• Поле ввода не всегда подхватывает фокус.

Файлы проекта

Исходники можно забрать с GitHub, либо скачать zip-архив с проектами для Android Studio и Eclipse.

Описанные примеры находятся в пакете com.examples . Все примеры можно без изменений запускать на обычном ПК (run everywhere!).

Источник

Оцените статью