Langsung ke konten utama

How to make J2ME Apps On Termux

To make J2ME Apps or maybe games, you will need to install OpenJDK (done via `apt install openjdk-xx` xx is the version number), Download the CLDC&MIDP jar files (download them from jarcasting).


Create a new java file for the main program, called HelloMIDlet.java:

```
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;


public class HelloMIDlet extends MIDlet {
        private Display display;
        private Form form;

        public HelloMIDlet() {
                form = new Form("Hello World from J2ME!");
        }

        protected void startApp() {
                display = Display.getDisplay(this);
                form.append(new StringItem("Message:", "Hello, World!"));
                display.setCurrent(form);
        }

        protected void pauseApp() {
        }

        protected void destroyApp(boolean unconditional) {
        }
}
``` 

Save it, then compile:

`javac -source 8 -target 8 -bootclasspath "cldcapi11-2.0.3.jar:midpapi20-2.0.4.jar" -d classes *.java`


Create the manifest file manifest.txt contains:

```

MIDlet-Name: MyAwesomeApp                                         

MIDlet-Version: 1.0

MIDlet-Vendor: MyCompany

MIDlet-1: MyApp, /icon.png, HelloMIDlet

MicroEdition-Configuration: CLDC-1.1

MicroEdition-Profile: MIDP-2.0

```


Package the classes and manifest and any additional files:

`jar cvm manifest.txt -C ./classes . > myapp.jar`


Install the packaged jar using the J2ME Emulator.


Komentar