Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run pure java code in Android Studio?

I am used to Android Studio and don't want to use other ide for Java development. How do I run pure java in Android Studio?

like image 407
mayank1513 Avatar asked Jul 15 '26 12:07

mayank1513


1 Answers

See this post.

In main menu-bar, go to File -> New -> New Module

enter image description here

Now scroll down to the bottom and select Java Library in the window that pops up

enter image description here

click next and set the package name in next screen

enter image description here

Click Finish. Android Studio will create Java Library Module for you. You are ready to code. All the short-cuts, key-mappings, auto-complete and scaffolding of IntelliJ platform is available for you to speed up your coding.

You can find your newly created Java Library in the Android scope in Project Navigator

enter image description here

You can add as many classes and packages you need.

Scaffolding

Enter psvm (short for public static void main) and press enter to create your main method.

Once the method is created you will see green play button next to method and class to allow you to run your program.

enter image description here

Happy Coding!!!

like image 179
mayank1513 Avatar answered Jul 20 '26 13:07

mayank1513



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!