简体   繁体   中英

How to compile a JavaBean?

I'm learning JavaBeans and it's application I'm creating my first ever Bean, I use an IDE called JCreator(free) which I have been using so far for the the compilation process of Servlets and I transfer the .class file to the local Apache server.

In my lecture notes it states that I need to store the JavaBeans I create in a package, which according to my understanding should reside inside the JDK version I use, am I right? The notes talk about the following command to line method for this

javac -d. newBean.java

I use a local folder in my E: drive to store all the Java files I create and compile them there, obviously I move the class files in to the classes folder in my WEB-INF in my Apache which is located in local C:

One way to solve the assignment requirements.

Assuming a directory structure as follows:

C:\projects\stackoverflow\3748425>dir /s
 Volume in drive C is WINVISTA
 Volume Serial Number is 3079-C372

 Directory of C:\projects\stackoverflow\3748425

09/19/2010  07:55 PM              .
09/19/2010  07:55 PM              ..
09/19/2010  07:56 PM              beans
               0 File(s)              0 bytes

 Directory of C:\projects\stackoverflow\3748425\beans

09/19/2010  07:56 PM              .
09/19/2010  07:56 PM              ..
09/19/2010  07:58 PM               540 Bean1.class
09/19/2010  07:57 PM               357 Bean1.java
               2 File(s)            897 bytes

     Total Files Listed:
               2 File(s)            897 bytes
               5 Dir(s)  170,347,962,368 bytes free

And a Java source code file...


package beans;

public class Bean1 implements java.io.Serializable {

  private String a;
  private String b;

  public Bean1(){}

  public void setA(String a){
    this.a = a;
  }

  public void setB(String b){
    this.b = b;
  }

  public String getA(){
    return this.a;
  }

  public String getB(){
    return this.b;
  }

}

You can compile it with this command:

javac -d . beans\Bean1.java

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