Java Engineering / JAVA FUNDAMENTALS / JAV-001

Build Doctor

Explore concept graph

Latihan soal

Proof lokal: compile vs runtime

Fixture kecil berikut dieksekusi pada JDK 21, tanpa Maven atau dependency eksternal.

java generation/fixtures/JAV-001/BuildDoctorFixture.java

Ia memanggil JavaCompiler untuk menghasilkan kegagalan simbol yang disengaja, membuat class valid, menghapus satu class runtime, lalu memulihkannya. Output yang diharapkan:

java-version=21
compile-missing-symbol=failed
runtime-missing-class=NoClassDefFoundError
restored-run=ready

Batas proof: output tersebut membuktikan Java 21 compiler dan JVM class-loading behavior, bukan bahwa Maven clean verify, dependency scopes, atau distribusi java -jar sudah diuji. Praktik Maven sungguhan berada di Project.

Konsep 1 / 3

Identify the Java 21 JDK, javac and java runtime and distinguish a compile-time missing symbol from runtime class loading.

Coba prediksi atau perbaiki

mvn -version uses Java 17, but your IDE is set to Java 21. What should you check before editing application logic?

Kalau jawabanmu berbeda

Kesalahan yang mungkin: Assuming IDE project SDK automatically controls the Maven process.

Mengapa tidak bekerja: Maven can resolve another java executable and cannot compile Java 21 code with an older JDK.

Coba perbaiki: Compare Maven's reported Java home and the compiler release configured in pom.xml.

Periksa hasil sendiri

Hasil yang diharapkan: Maven and javac report Java 21 or a compatible compiler target for the intended release.

Kalau berbeda: Inspect PATH, JAVA_HOME and the first compiler diagnostic rather than guessing from a green IDE.

Konsep 2 / 3

Explain compile, runtime, test and provided Maven dependency scope using failure evidence.

Coba prediksi atau perbaiki

A library directly imported from src/main/java is marked runtime in pom.xml. Why might javac fail?

Kalau jawabanmu berbeda

Kesalahan yang mungkin: Treating compile, runtime, provided and test scopes as interchangeable labels.

Mengapa tidak bekerja: Maven deliberately builds distinct classpaths for compilation, tests and execution.

Coba perbaiki: Choose scope based on where the class is required and inspect packaged runtime dependencies separately.

Periksa hasil sendiri

Hasil yang diharapkan: Main code compiles only when required types are available on its compilation classpath.

Kalau berbeda: Read the first javac error, Maven effective POM and dependency tree before changing versions blindly.

Konsep 3 / 3

Verify a Java 21 Maven build and a runnable executable JAR without relying on IDE state.

Coba prediksi atau perbaiki

mvn clean verify succeeds, but java -jar reports 'no main manifest attribute'. Do you fix dependency scope first?

Kalau jawabanmu berbeda

Kesalahan yang mungkin: Assuming Maven compilation automatically produces an executable self-contained JAR.

Mengapa tidak bekerja: Main-Class manifest and third-party runtime libraries are separate from successful compilation.

Coba perbaiki: Inspect the manifest, runtime classpath and release property, then rerun the packaged artifact.

Periksa hasil sendiri

Hasil yang diharapkan: The Java 21 fixture reports missing-symbol compile failure, missing runtime class and successful restored execution.

Kalau berbeda: Inspect the first actual compile failure, Main-Class metadata and runtime classpath independently.

Lima soal debugging

Jawab tanpa melihat pembahasan dulu. Kamu bisa memperbaiki jawaban dan mencoba lagi. Kuis ini latihan mandiri dan tidak menyimpan skor atau progres.

javac gagal dengan 'cannot find symbol: MissingLibrary'. Apa tahap kegagalannya?
Main.class berhasil dikompilasi tetapi java -cp gagal dengan NoClassDefFoundError. Apa tersangka awal?
Library dipakai oleh src/main/java tetapi Maven scope test. Akibat yang paling mungkin?
Mengapa main source yang mengimpor dependency dengan scope runtime dapat gagal compile?
mvn clean verify sukses tetapi java -jar gagal: no main manifest attribute. Tindakan tepat?