Search code examples
javaandroidbootclasspath

replacement for bootclasspath option in java


I am trying to build an Android app manually just from the command line without using any kind of extra things, such as the build system (Gradle). I am following this page.

But, I am stuck at compiling the Java source files.
Whenever I am issuing the command :
javac -d obj -classpath src -bootclasspath E:/.android/sdk/platforms/android-10/android.jar src/com/example/hello/MainActivity.java
(My Android SDK is in E:/.android/SDK folder)
I am getting
error: option --boot-class-path not allowed with target 12
I am using JDK version 12.0.2. I came to know that the boot-class-path option was removed since JDK version 9. So, how to compile the Java source files? What is the alternative to the boot-class-path option in JDK 12.0.2?


Solution

  • Java 9 and beyond don't support the bootclasspath option, but the bootclasspath can also be treated as a normal classpath. I had included the bootclasspath path with classpath and it worked.

    javac -d obj -classpath src -bootclasspath E:/.android/sdk/platforms/android-10/android.jar src/com/example/hello/MainActivity.java

    I just removed the -bootclasspath and included the path to android.jar into classpath.

    javac -d obj -classpath src;E:/.android/sdk/platforms/android-10/android.jar src/com/example/hello/MainActivity.java