本文介绍了Java 测试包不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,我有 /home

class Test {
    public static void main(String[] args) {
        prog.io.ConsoleOutputManager out=new prog.io.ConsoleOutputManager();
        pack1.A a=new pack1.A();
        out.println(a.toString());
    }
}

这给了我错误:

Test.java:3: error: package prog.io does not exist
prog.io.ConsoleOutputManager out=new prog.io.ConsoleOutputManager();
^
Test.java:3: error: package prog.io does not exist
prog.io.ConsoleOutputManager out=new prog.io.ConsoleOutputManager();
^
Test.java:5: error: package pack1 does not exist
pack1.A a=new pack1.A();
^
Test.java:5: error: package pack1 does not exist
pack1.A a=new pack1.A();
^
4 errors

pack1pack2prog.io 也在 /home 中......为什么它没有没找到吗?

pack1, pack2 and prog.io are in /home as well..Why it doesn't find them?

推荐答案

请确保您已设置类路径,以便它可以找到您在代码中使用的包.

Please make sure that you have set the classpath such that it can find the packages that you are using in your code.

这篇关于Java 测试包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 23:30