Run Java project in Android studio

You can ability to compile and run java module as stand alone java project in Android Studio IDE.

  1. Open your Android project in Android Studio. If you do not have one, create one.
  2. Click File > New Module. Select Java Library and click Next.
  3. Fill in the package name, etc and click Finish. You should now see a Java module inside your Android project.
  4. Add your code to the Java module you’ve just created.
  5. Click on the drop down to the left of the run button. Click Edit Configurations…
  6. In the new window, click on the plus sign at the top left of the window and select Application
  7. A new application configuration should appear, enter in the details such as your main class and classpath of your module.

Now if you click run, this should compile and run your Java module.

3 thoughts on “Run Java project in Android studio

  1. Thank you for this nice tutorial. I just want to add, that once you create your Java module, with your Java class inside of it, all you have to do is right-click on this class to run it. No need to edit configurations in this case.

Leave a comment