简体   繁体   English

在包中使用Java类(vim + eclim)

[英]Using java classes in package (vim + eclim)

When you create new java class with vim, save it and leave it open on seperate vim instance, apparently you can't use that class untill that vim instance with opened class is closed. 当用vim创建新的Java类时,将其保存并在单独的vim实例上保持打开状态,显然,只有在关闭带有打开类的vim实例之后,才能使用该类。

Update: Or not... Tried to replicate issue but now it just works... Haven't changed anything. 更新:否。。。试图复制问题,但现在可以使用了。。。 Just added new class to package, and I can use it from Main.java... 刚刚在包中添加了新类,我可以从Main.java中使用它。

Problem solved. 问题解决了。

I have a package org.test and in that package there are the Main.java and Test.java classes. 我有一个org.test软件包,并且在该软件包中有Main.javaTest.java类。

But for some reason Main.java (which has the main method) can't find the Test.java class (which, I repeat, are both in the same package). 但是由于某种原因, Main.java (具有main方法)找不到Test.java类(我重复说,它们都在同一包中)。

I tried import org.test.*; 我尝试import org.test.*; , but still nothing... ,但还是一无所有...

here's code (if necessary) 这是代码(如有必要)

Main.java Main.java

package org.test;

public class Main{

    public static void main(String[] args){
        Test newTest = new Test();
    }
}

Test.java Test.java

package org.test;

public class Test{

// doesn't matter if anything is here
}

In Main.java I get 在Main.java中,我得到了

Test cannot be resolved to a type.

Any help? 有什么帮助吗? Everything works when I don't use a package. 不使用包装时一切正常。

If it helps, when I try in Main: 如果有帮助,当我尝试Main:

import org.test.Test;

autocomplete doesn't find Test and when I save file I get error 自动完成找不到测试,当我保存文件时出现错误

The import org.test.Test cannot be resolved.

One more time: both Main.java and Test.java in same package (org.test). 再过一次:Main.java和Test.java都在同一个包中(org.test)。

Maybe I need change something in settings? 也许我需要更改设置吗? I assume eclipse everything does automagicaly in this case, but I don't really know what and where should I change... 我认为在这种情况下,日食会自动完成,但是我真的不知道应该在什么地方更改。

When you create new java class with vim, save it and leave it open on seperate vim instance, apparently you can't use that class untill that vim instance with opened class is closed. 当用vim创建新的Java类时,将其保存并在单独的vim实例上保持打开状态,显然,只有在关闭带有打开类的vim实例之后,才能使用该类。

Update: Or not... Tried to replicate issue but now it just works... Haven't changed anything. 更新:否。。。试图复制问题,但现在可以使用了。。。 Just added new class to package, and I can use it from Main.java... 刚刚在包中添加了新类,我可以从Main.java中使用它。

Problem solved. 问题解决了。

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

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