我创建了一个包:

路径:/ home / myid / py_ejb
档案:XmppMnager.java

package xmpp;

import org.jivesoftware.smack.Chat;
public class XmppManager {
}


编译与

javac -d . -classpath .:smack.jar XmppManager.java


档案:XmppTest.java

import xmpp.*;

public class XmppTest {

    public static void main(String[] args) throws Exception {

        String username = "testuser1";
        String password = "testuser1pass";

        XmppManager xmppManager = new XmppManager("myserver", 5222);

..}


编译与

$ javac  -classpath .:smack.jar:./xmpp XmppTest.java
XmppTest.java:10: cannot access XmppManager
bad class file: RegularFileObject[./xmpp/XmppManager.class]
class file contains wrong class: xmpp.XmppManager
Please remove or make sure it appears in the correct subdirectory of the classpath.
        XmppManager xmppManager = new XmppManager("myserver", 5222);
        ^
1 error


我尝试了很多方法来解决此编译问题,但它并没有消失

最佳答案

将源文件移动到名为xmpp的文件夹中,以便程序包名称与该文件夹的名称匹配

10-08 00:18