简体   繁体   中英

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.

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...

Problem solved.

I have a package org.test and in that package there are the Main.java and Test.java classes.

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).

I tried import org.test.*; , but still nothing...

here's code (if necessary)

Main.java

package org.test;

public class Main{

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

Test.java

package org.test;

public class Test{

// doesn't matter if anything is here
}

In Main.java I get

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:

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).

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.

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...

Problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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