Eclipse Plugin project with other project dependencies

后端 未结 2 1140
长情又很酷
长情又很酷 2021-01-17 21:20

I have an Eclipse plugin project, and it depends on other projects that I have in my Eclipse workspace. After adding the project dependencies under \"Java Build Path\" -> \"

相关标签:
2条回答
  • 2021-01-17 21:59

    In case if you're not in a position to copy the dependent project into your plugin project and you are sure about the presence of the dependent project in the target eclipse where plugin is to be installed, then you can either use Runtime.exec() to run the Java class you want to run or ProcessBuilder class to run the class.

    Like this:

    // To compile
    Process p = Runtime.getRuntime().exec("javac yourclass.java"); 
    // To execute
    Process p2 = Runtime.getRuntime().exec("java yourclass");
    

    This may be considered in the worst case. I had such an experience and hence thought some may find it useful.

    0 讨论(0)
  • 2021-01-17 22:00

    An Eclipse plug in project manages dependencies differently than a regular Java project.

    I'm assuming that you're adding packages with .class files.

    Define a library folder in your Eclipse plug-in project. Copy any external classes and / or jars to the library folder.

    Open up the MANIFEST.MF file under the META-INF directory. You'll see a formatted editor with 8 tabs on the bottom.

    Click on the Runtime tab. Add the external classes and / or jars in the library folder to the Classpath. This will also add these external classes and or jars to the Java Build Path of the project.

    Click on the Dependencies tab, and add the other Java projects in the Imported Packages dialog. You have to check the box labeled "Show non-exported packages". If your other Java projects are Eclipse plug ins, add them under Required Plug-ins instead.

    0 讨论(0)
提交回复
热议问题