A
A
Alexey Petrov2021-03-18 10:13:22
Java
Alexey Petrov, 2021-03-18 10:13:22

How to execute compiled java class on android?

Hello. I want to be able to compile and execute simple Java classes directly on an Android 10 device.
Installed Termux and ecj. Created a simple class in the editor.

public class TestClass  
{
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

With the help of ecj, I compiled and received the file TestClass.class , now I'm looking for how to execute it. Somewhere I found that it seems that dalvik should run it, but how exactly is not described. Tried just
$ dalvikvm TestClass
getting

Unable to locate class 'TestClass' java.lang.ClassNotFoundException: TestClass Exception in thread "main" java.lang.ClassNotFoundException: TestClass

I tried to specify the path relative and absolute in the "-cp" option, but the result is the same. What is needed to complete the class?

UPD: For some reason, I could not run the main.dex file generated by AIDE using dalvikvm, but this is probably a topic for a separate question.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2021-03-18
@Oegir

It seems to me that you should not bother, but take AIDE . There you can build / run Java, android applications, and C ++ to the heap.

D
Dmitry Alexandrov, 2021-03-18
@jamakasi666

You need jdk\jre, there were ports for termux.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question