How do I use classes from another project in IntelliJ IDEA?

前端 未结 3 1393
萌比男神i
萌比男神i 2020-12-17 08:43

I have two IntelliJ IDEA Java projects; ProjectA and ProjectB. I want to import and use code from ProjectA in ProjectB. How do I do this?

In Eclipse I would simply g

3条回答
  •  孤城傲影
    2020-12-17 09:22

    you have to create a module of your Project A and add in the path of your project B.

    Follow this link for learn how to create module and use it in other project : Creating a module library

    Hope i help you

    EDIT : ok so you have to create a module or a package with your Project A a .jar.

    after do this, go to File -> project structure.

    On this windows go to Librairies -> click on + and select your module project B.jar.

    and Now you have to import your librairie in your class like
    import projectb.*;

    now instancie the class you want to use and you can use all of the method of this class

    hope i help you with that precision

提交回复
热议问题