Tôi có một số mã Java di sản, tức là .:thêm module java 9 hệ thống để biên dịch trong eclipse
package org.alo.test.j9;
import javax.activation.DataHandler; // in java.activation module
import javax.annotation.PostConstruct; // in java.xml.ws.annotation module
public class OldClass {
public static void main(String[] args) {
DataHandler dh = new DataHandler(null, null);
System.out.println(dh);
}
}
Đó là chưa module nên nó đòi hỏi phải sử dụng --add-modules
để biên dịch nó với Java 9.
$ javac -version
javac 9
$ javac org/alo/test/j9/OldClass.java
src/org/alo/test/j9/OldClass.java:3: error: package javax.activation is not visible
import javax.activation.DataHandler; // in java.activation module
^
(package javax.activation is declared in module java.activation, which is not in the module graph)
src/org/alo/test/j9/OldClass.java:4: error: package javax.annotation is not visible
import javax.annotation.PostConstruct; // in java.xml.ws.annotation module
^
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)
2 errors
tôi cần phải thêm các module tôi đang sử dụng để có thể thành công biên soạn:
$ javac org/test/OldClass.java --add-modules=java.activation,java.xml.ws.annotation
Tôi muốn biên dịch nó trong Eclipse (sử dụng Oxygen.1a) với Java 9. Nhưng tôi nhận được The import javax.activation cannot be resolved
lỗi biên dịch.
Làm cách nào tôi có thể cho trình biên dịch nhật thực thêm các mô-đun này? Tôi không tìm thấy bất kỳ mẹo nào trong số Eclipse documentation về điều đó.
Here bạn có thể tìm thấy một dự án nhật thực đơn giản mà tôi đang thử nghiệm.
Bản sao có thể có của [Thay thế cho gói javax.activation trong java 9 là gì?] (Https://stackoverflow.com/questions/46493613/what-is-the-replacement-for-javax-activation-package- trong-java-9). Lý do của nó không được chấp nhận và nâng cấp. – nullpointer
@nullpointer Đó không phải là một bản sao của câu hỏi này. –
Trong trường hợp đó, bạn có thể chia sẻ cấu hình Chạy của Eclipse được sử dụng với các thiết lập dự án cùng với không? – nullpointer