Package other projects and projects referenced in eclipse

Source: Internet
Author: User

1. Create Project project1
2. Create the class file classa

[Java]
View plaincopyprint?
    1. PackageCom. test;
    2. Public ClassClassa {
    3. Public StaticString getclassa (){
    4. Return "Classa data";
    5. }
    6. }

Package COM. test; <br/> public class classa {<br/> Public static string getclassa () {<br/> return "classa data "; <br/>}< br/>}
3. Right-click and choose "Export"> "JAR file" under "Java"> "Next"> select the class file to be included in the package,
JAR file directory select the Save location and enter the JAR file name (D:/temp. Jar) --> finish
4. Create a Project
5. Right-click projectb --> properties --> JAVA buil path --> libraries --> Add externel jar --> select D:/temp. jar --> OK

6. Create a file classb

[Java]
View plaincopyprint?
    1. package com;
    2. Import com. Test. classa;
    3. Public class classb {
    4. Public static void main (string [] ARGs) {
    5. system. Out. println (classa. getclassa ();
    6. }
    7. }

Package com; <br/> Import COM. test. classa; <br/> public class classb {<br/> Public static void main (string [] ARGs) {<br/> system. out. println (classa. getclassa (); <br/>}< br/>
In this way, you can

You don't need to package the classes that you want to reference other projects.
Projectb --> right-click --> Property --> JAVA buil path --> projects --> Add --> select projecta --> OK

 

Respect others' labor achievements. Please refer to the post for self-conversion.

Http://blog.csdn.net/swandragon/archive/2009/10/13/4665283.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.