简体   繁体   English

Do-While 循环在输入用户输入时显示很多错误(Java -OSGi Equinox in Eclipse EE

[英]Do-While loop is showing a lot of error while entering user input (Java -OSGi Equinox in Eclipse EE

I am new to OSGi Equinox.我是 OSGi Equinox 的新手。 I am trying to do a Producer-Consumer sample.我正在尝试做一个生产者-消费者样本。 I have one consumer and 2 producers.我有一个消费者和两个生产者。 When I run the project everything is working fine.当我运行该项目时,一切正常。 Services started and working successfully.服务启动并成功运行。

In the consumer I have a Do-While loop where if user enter "no" the loop will continue.在消费者中,我有一个 Do-While 循环,如果用户输入“否”,循环将继续。 If they type "yes" or any other, the loop needs to stop and execute the function I have mentioned.如果他们输入“yes”或其他任何内容,循环需要停止并执行我提到的 function。

"no" command is working successfully. “no”命令运行成功。 But if I type yes or anything it is showing a lot of errors.但是,如果我输入 yes 或任何内容,则会显示很多错误。 This is the beginning of the error.这是错误的开始。 (I can provide full error if needed) (如果需要,我可以提供完整的错误)

错误

This is the Do-While loop I have.这是我的 Do-While 循环。 I tried running the SubMethod.PrintBill() function, but still got the same error.我尝试运行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();
    
}

Do I need to add any dependencies related to (OSGi) or anything to resolve the issue?我是否需要添加与 (OSGi) 相关的任何依赖项或任何解决问题的内容? Can someone explain why this error is coming and how to resolve it?有人可以解释为什么会出现这个错误以及如何解决它吗?

I think the whole code of the project is not necessary.我认为项目的整个代码是不必要的。 But if needed please ask.但如果需要请询问。 I can provide.我可以提供。

Thank-you in advance.先感谢您。

This is completely unrelated to any Java code (while loop or anything).这与任何 Java 代码(while 循环或任何东西)完全无关。

Your module (OSGi bundle) com.sun.xml.bind with ID 22 can't be resolved .您的模块(OSGi 捆绑包) com.sun.xml.bind with ID 22 can't be resolved The reason is that another module (OSGi bundle) can't be resolved and this module is a bundle with javax.activation symbolic name.原因是无法解析另一个模块(OSGi 包),并且该模块是一个带有javax.activation符号名称的包。

The exact reason why javax.activation is not resolved is that it requires JDK 9, while you're probably using JDK 8 (or earlier). javax.activation未解决的确切原因是它需要 JDK 9,而您可能使用的是 JDK 8(或更早版本)。

The version of javax.activation you're using is 1.2.2.v20201119-1642 , which means it is NOT an official bundle available in:您使用的javax.activation版本是1.2.2.v20201119-1642 ,这意味着它不是官方捆绑包,可用于:

You're probably using some repackage version of Activation API from Eclipse repositories.您可能正在使用来自 Eclipse 存储库的激活 API 的某些重新打包版本。 Please either use JDK11+ or replace the Activation bundle with the official one.请使用 JDK11+ 或将激活包替换为官方包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM