Tutorial #1: Running Java Code on Android Studio Without Any Android Component
Before Android Studio, we were using Eclipse that was first designed for Java. But, for running Java code without any help of Android components. You have to follow some steps:
- Install The Android Studio, if haven't installed it already. Here is the link describing the whole process of installation: https://developer.android.com/studio/install.html
- After the installation is completed, start Android Studio and start a new project. It will take some time, as the preliminary settings for a project like Gradle sync and Indexing are in process.
- After creating a project. Goto File>> New>>New Module.
- Select Java Library from the icons given and click Next.
- After that give names to library and class and click Finish.
- You will see the library opened up in the project, open the class and define the main function, as it is default function for running any Java code.
public static void main(String[] str){ }
- Now, wait again. After the sync process is completed, goto the Run>>Edit Configurations.
- Here at the top, click the Green Add option, fill in any Name, search for the class location, and library directory and click finish.
- After this, you can run any code in the same class, where you have defined the main function.
Here is the video of the whole process.
Comments
Post a Comment