tags:

views:

64

answers:

1

Hi All, I'm a student and a newbie when it comes to Java web technologies such as JavaBeans, Servlets and JSP etc. So please bare with me on this one

At the moment I'm in the process of 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:

A: 

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
jtp
Hi JT thanks for the reply; my directory structure where all my java files and class files are saved is as follows: E:\Personal\BInfoTech\Practicals\Java this is my current location, assuming this can you please explain to my how to copile the Bean, as usual my JDK is in C:\
Kushan
@Kushan - I was basing my answer on the information provided from the lecture notes and the fact that you listed the "javac -d ." command. In my experience, professors prefer the JDK programs (javac, java) to the use of IDEs. Try taking my example and saving it in your E:\Personal\BInfoTech\Practicals\Java\beans\Bean1.java and use the listed javac command from the directory E:\Personal\BInfoTech\Practicals\Java. This assumes that the JDK\bin directory is in your environment path. The result should be a Java class in E:\Personal\BInfoTech\Practicals\Java\beans\Bean1.class. I hope that helps.
jtp
Thanks JT, that certainly helps, funny you say that, our lecturer actualy wanted us to use the IDE
Kushan
You are welcome Kushan. The lecturer knows best. IDEs generally make Java development much, much smoother :)
jtp
JT, thought I'd let you know, it works like a charm, I wrote the code in the IDE but compiled using your method in command line, thanks again
Kushan
That's great news Kushan. Does JCreator compile it too?
jtp
No JCreator as in the case of most IDE a set path that is defined at the installation of the software, which can be changed, but it's too much trouble \, much more feasible to do it on command line
Kushan