كيف يُنفَّذ الكود
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- الكود المصدري، الترجمة، الشيفرة الوسيطة (bytecode)، التنفيذ، أخطاء وقت التشغيل
- مترجم Java وJVM وJRE وJDK
تعلّم أولًا
57 دقيقة قراءة · 1.5 ساعة تدريب (تقدير)
مخرجات التعلم
- Explain the difference between source code, bytecode, and machine code.
- Distinguish JDK, JRE, and JVM and say which one a developer needs.
- Compile a
.javafile withjavacand run the resulting class withjavafrom the terminal. - Distinguish a compile-time error from a runtime error, given an example of each.
الدروس
المختبر والتمارين
Lab
BEG-007-LAB1 · Hello from the terminal
Outcomes: 1–4 · Time: ~1.5 h
- Type the provided Hello program, compile it with
javac, and run it withjava. - Look at the generated
.classfile. - Introduce a syntax error and record the compile-time message.
- Introduce a division-by-zero error and record the runtime message.
- Run the same program in IntelliJ.
Acceptance: both messages captured and each classified correctly.
Exercises
| ID | Outcome | Task |
|---|---|---|
| BEG-007-EX01 | 1 | Put in order: machine code, source code, bytecode. |
| BEG-007-EX02 | 1 | Why can the same .class file run on Windows and Linux? |
| BEG-007-EX03 | 2 | Draw JDK, JRE, and JVM as nested boxes. |
| BEG-007-EX04 | 2 | Which one do you install to write Java, and why? |
| BEG-007-EX05 | 3 | Compile and run a program from the terminal; list the two commands. |
| BEG-007-EX06 | 3 | java Hello.class fails. Why, and what is the fix? |
| BEG-007-EX07 | 4 | Classify: a missing semicolon; dividing by zero; a typo in a variable name. |
أظهر الحلول
- EX01 Source code → bytecode → machine code.
- EX02 Each OS has a JVM that runs the same bytecode.
- EX03 JVM inside JRE inside JDK.
- EX04 The JDK, because it includes the compiler.
- EX05
javac Hello.javathenjava Hello. - EX06
javaexpects the class name, not the file name. Usejava Hello. - EX07 Compile-time; runtime; compile-time.
الاختبار
Outcomes: O1 source/bytecode/machine code · O2 JDK/JRE/JVM · O3 compile and run · O4 error kinds.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Explain the compile/run pipeline aloud while demonstrating it: write, javac, show .class, java. Pass: all four steps and the name of each file involved.
أخطاء شائعة
Class name not matching file name; running java Hello.class; confusing "it compiled" with "it works".
التقييم
Explain the compile/run pipeline aloud while demonstrating it.
الصلة بالمسار الوظيفي
Basis for build tools (BEG-054) and JVM internals (MID-001).