redhat-developer / redhat-developer/vscode-java
supposed compilation errors when using java 17 modules in visual studio code
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.3k
- Fork
- 546
- Merge trung bình
- 20 giờ 1 phút
- Pull request đã merge (30 ngày)
- 11
Mô tả
Environment
- Operating System: windows 11
- JDK version: "17.0.7" 2023-04-18 LTS
- Visual Studio Code version: 1.84.0 user setup
- Java extension version: v.0.25.15
When I create the following code I get a compilation error saying that certain packages do not exist. The steps I followed are:
1. create a project in java in my case it is called OCP JAVA 17 2. create a folder called 12. Modules (within this folder is the directory with program codes and modules written in Java 17) 3. create a folder called feeding 4. inside the feeding folder, create a module-info.java file with the following codemodule zoo.animal.feeding { exports zoo.animal.feeding; }5. inside the feeding folder, create a package or folders in the following order zoo/animal/feeding and add the Task.java file with the following codepackage zoo.animal.feeding; public class Task { public static void main(String... args) { System.out.println("All fed!"); } }6. compile Task.java class and module-info.java with following command in terminal opening from 12.Modules folder javac -p mods -d feeding feeding/zoo/animal/feeding/Task.java feeding/*.java 7. create a folder called mods and run the following command in the terminal to package our compiled code from the 12.Modules folder jar -cvf mods/zoo.animal.feeding.jar -C feeding/ . 8. run the program by entering the following command in the terminal from 12.Modules java -p mods -m zoo.animal.feeding/zoo.animal.feeding.Task must be printed in console All fed! 9. create a folder called care with the following file module-info.java with the codemodule zoo.animal.care { exports zoo.animal.care.medical; //here is vsc supposed compilation error requires zoo.animal.feeding; }10. inside the care folder create 2 packages/folders in the following order zoo/animal/care/details and zoo/animal/care/medical 11. in the zoo/animal/care/details package add the following file HippoBirthday.java// HippoBirthday.java package zoo.animal.care.details; import zoo.animal.feeding.*; public class HippoBirthday { private Task task; public static void main(String... args) { //mio System.out.println("Feliz cumple"); //mio } }12. in the zoo/animal/care/medical package add the following Diet.java file// Diet.java package zoo.animal.care.medical; public class Diet { public static void main(String... args) { //mio System.out.println("Diet"); //mio } }13. compile and package what is inside the care folder, in the terminal from 12.Modules with the following command javac -p mods -d care care/zoo/animal/care/details/_.java care/zoo/animal/care/medical/_.java care/module-info. javajar -cvf mods/zoo.animal.care.jar -C care/ . 14) run the classes that are inside the zoo.animal.care.medical package (which vsc says does not exist) in terminal from 12.Modules java -p mods -m zoo.animal.care/zoo.animal.care.medical.Diet the word Diet should be printed in the console
If the program runs properly, there should be no reason for vsc to mark an error in red, such as in the module-info.java file in the care folder that says that the package zoo.animal.care.medical does not exist. Your help please
attached screenshots
![]()
VS Code version: Code 1.84.0 (d037ac0, 2023-11-01T11:29:04.398Z) OS version: Windows_NT x64 10.0.22621 Modes:
System Info
Extensions (15)
A/B Experiments
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện báo cáo bằng các tệp module-info.java, Task.java, HippoBirthday.java và Diet.java được hiển thị, cùng các lệnh javac, jar và java được liệt kê. So sánh việc biên dịch thành công trong terminal với chẩn đoán màu đỏ trên care/module-info.java, sau đó theo dõi cách tiện ích mở rộng Java xử lý bố cục mô-đun này. Hoàn tất khi package hợp lệ không còn bị báo là bị thiếu, hoặc vấn đề đã có lời giải thích được ghi chép nếu chẩn đoán này là điều được mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, vscode
- Lĩnh vực
- developer-experience, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100
