Buy 2 – Save 10% + FREE SHIPPING

Buy 2 – Save 10%

To Apk For Android - How To Convert Jar File

If you have a headless JAR, wrapping it into an APK is straightforward. If it has a desktop GUI, you’re better off rewriting the UI for Android.

// In your Activity new Thread(() -> { PrintStream originalOut = System.out; ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); System.setOut(ps); YourJarMainClass.main(new String[]{}); how to convert jar file to apk for android

String result = YourClass.someMethod(); TextView tv = findViewById(R.id.textView); tv.setText(result); If you have a headless JAR, wrapping it

System.out.flush(); String output = baos.toString(); runOnUiThread(() -> textView.setText(output)); }).start(); That’s not conversion — that’s rewriting or recompiling. If you have a headless JAR

import com.yourjarpackage.YourClass; public class MainActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

In MainActivity.java :

Shopping cart

We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.

More info