aspose file tools*
The moose likes Servlets and the fly likes Help! Difficult in compiling Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help! Difficult in compiling Servlets" Watch "Help! Difficult in compiling Servlets" New topic
Author

Help! Difficult in compiling Servlets

Tazzmission
Greenhorn

Joined: Jan 16, 2002
Posts: 20
Hi, I've 2 java
a.java which will user b.java
in a.java and b.java, I've package hello; in first line,
and I've saved a.java and b.java to e:\tomcat\webapps\examples\web-inf\classes\hello
inside hello directory, I compile by using "javac a.java" but it failed saying it can't find b.java,
however if I say a.java and b.java in classes\ , it have no problem in compiling.
Pls tell me how to compile the two java using in \hello\?
Thanks
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Tazzmission",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please re-register and select a new name which meets the requirements.
Thanks.
Dave
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
alright,i've re-registered


Thanks everyone who helped me
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
A typo in my question , user->use:
Hi, I've 2 java a.java which will use b.java (create a object of b.java)in a.java and b.java, I've package hello; in first line, and I've saved a.java and b.java to e:\tomcat\webapps\examples\web-inf\classes\hello
inside hello directory, I compile by using "javac a.java" but it failed saying it can't find b.java,
however if I say a.java and b.java in classes\ , it have no problem in compiling.
Pls tell me how to compile the two java using in \hello\?
Thanks
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

You probably are compiling it from the hello directory, right?

It will look for your b.java from the current directory. So if you are compiling the file located at: <>/classes/hello/a.java *FROM* the hello directory,

It will try to find:
<>/classes/hello/hello/b.java

The solution I would use goes something like this:
<> = (whatever the path is up to and including WEB-INF)

<>/src
<>/classes

<>/src/hello/a.java
<>/src/hello/b.java

From the <>/src directory (that's important)
javac -d ../classes hello/a.java

The -d switch tells the compiler to place the compiled classes in a certain directory, in this case, the classes directory.
[ January 23, 2002: Message edited by: Mike Curwen ]
Raj Mohan
Ranch Hand

Joined: Sep 26, 2000
Posts: 73
you can set classpath to avoid this problem
set classpath=%classpath%; e:\tomcat\webapps\examples\web-inf\classes;
now you can compile in hello package.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Thanks everyone,
I have solved it now,
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help! Difficult in compiling Servlets