Java בעידן ה-AIJava in the AI era
עבודה נכונה עם עוזר AI, קריאה ל-API של מודל שפה מ-Java (עם תשובות מוקלטות מראש), ובדיקת מה שהמודל כתב.
Working well with an AI assistant, calling a language model API from Java (with recorded replies), and checking what the model wrote.
איך מריצים את הקוד של המפגשRunning this session's code
הפלט שמופיע ליד כל דוגמה הוא הפלט האמיתי שלה מהרצה על JDK 21. בתרגילים כותבים קוד בעורך שבעמוד, מעתיקים ל-IntelliJ ומריצים שם, ומדביקים את הפלט בחזרה: האתר משווה אותו לפלט של הפתרון שלנו. במחשב: ב-IntelliJ יוצרים מחלקה חדשה בתיקייה src, מדביקים ולוחצים על המשולש הירוק. בטרמינל: javac Main.java ואז java Main.
The output next to every example is its real output from a run on JDK 21. In the exercises you write code in the page's editor, copy it to IntelliJ and run it there, then paste the output back: the site compares it with our solution's output. On your computer: in IntelliJ create a new class in src, paste and click the green triangle. In a terminal: javac Main.java then java Main.
| פעולהAction | MacMac | WindowsWindows |
|---|---|---|
| קומפילציהCompile | javac Main.java | javac Main.java |
| הרצהRun | java Main | java Main |
| קובץ אחד בלי קומפילציה נפרדתOne file without a separate compile | java Main.java | java Main.java |
| לנסות שורותTry lines out | jshell | jshell |
| להריץ ב-IntelliJRun in IntelliJ | Ctrl+Shift+R | Ctrl+Shift+F10 |
פתרון בעיותTroubleshooting
| בעיהProblem | סיבהCause | פתרוןFix |
|---|---|---|
'javac' is not recognized / command not found: javac'javac' is not recognized / command not found: javac | ה-JDK לא מותקן, או שהתיקייה bin שלו לא ב-PATHThe JDK isn't installed, or its bin folder isn't on PATH | מתקינים JDK 21 (מפגש 1) ופותחים טרמינל חדש. ב-Windows בודקים את JAVA_HOME ואת PATHInstall JDK 21 (session 1) and open a new terminal. On Windows check JAVA_HOME and PATH |
class Main is public, should be declared in a file named Main.javaclass Main is public, should be declared in a file named Main.java | שם הקובץ לא זהה לשם המחלקה הציבוריתThe file name doesn't match the public class name | משנים את שם הקובץ (או את שם המחלקה) כך שיהיו זהים, כולל אותיות גדולותRename the file (or the class) so they match, capital letters included |