[英]Do-While loop is showing a lot of error while entering user input (Java -OSGi Equinox in Eclipse EE
我是 OSGi Equinox 的新手。 我正在嘗試做一個生產者-消費者樣本。 我有一個消費者和兩個生產者。 當我運行該項目時,一切正常。 服務啟動並成功運行。
在消費者中,我有一個 Do-While 循環,如果用戶輸入“否”,循環將繼續。 如果他們輸入“yes”或其他任何內容,循環需要停止並執行我提到的 function。
“no”命令運行成功。 但是,如果我輸入 yes 或任何內容,則會顯示很多錯誤。 這是錯誤的開始。 (如果需要,我可以提供完整的錯誤)
這是我的 Do-While 循環。 我嘗試運行SubMethod.PrintBill()
function,但仍然遇到相同的錯誤。
private void MainMethod() {
Scanner sc=new Scanner(System.in);
String user_option="no";
do {
int serviceType = SubMethod.find();
if(serviceType == 1) {
ServiceReference service_1 = context.getServiceReference(Vehicle_Interface.class.getName());
Vehicle_Interface Vehicle_Int =(Vehicle_Interface) context.getService(service_1);
SubMethod.vehicleService(Vehicle_Int);
context.ungetService(service_1);
}
else if(serviceType == 2) {
ServiceReference service_2 = context.getServiceReference(Food_Interface.class.getName());
Food_Interface Food_Int =(Food_Interface)context.getService(service_2);
SubMethod.foodService(Food_Int);
context.ungetService(service_2);
}
else {
System.out.println("");
}
System.out.println("Do you want to exit? \n 'yes' for YES \n 'no' for NO");
user_option = sc.next();
}while(user_option.equals("no"));
SubMethod.PrintBill();
}
我是否需要添加與 (OSGi) 相關的任何依賴項或任何解決問題的內容? 有人可以解釋為什么會出現這個錯誤以及如何解決它嗎?
我認為項目的整個代碼是不必要的。 但如果需要請詢問。 我可以提供。
先感謝您。
這與任何 Java 代碼(while 循環或任何東西)完全無關。
您的模塊(OSGi 捆綁包) com.sun.xml.bind
with ID 22
can't be resolved 。 原因是無法解析另一個模塊(OSGi 包),並且該模塊是一個帶有javax.activation
符號名稱的包。
javax.activation
未解決的確切原因是它需要 JDK 9,而您可能使用的是 JDK 8(或更早版本)。
您使用的javax.activation
版本是1.2.2.v20201119-1642
,這意味着它不是官方捆綁包,可用於:
您可能正在使用來自 Eclipse 存儲庫的激活 API 的某些重新打包版本。 請使用 JDK11+ 或將激活包替換為官方包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.