File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help! Difficult in compiling Servlets

 
Tazzmission
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alright,i've re-registered
 
Ken Shamrock
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone,
I have solved it now,
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic