my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Issue with compiling Java Files inside of Packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Issue with compiling Java Files inside of Packages" Watch "Issue with compiling Java Files inside of Packages" New topic
Author

Issue with compiling Java Files inside of Packages

Subir Mukherjee
Greenhorn

Joined: Jul 20, 2001
Posts: 10
I am trying to compile the following java classes which are arranged in a package structure.
1. Servlet class "BeerSelect002Servlet.java" is inside package
2. The above servlet class calls a plain Java File "BeerExpert.java" that resides inside subdirectory "model"

I am trying to pre-compile the servlet class along with the supporting java file and then place the compiled class files on App server.



The above servlet class calls the Java File below that is inside subdirectory "model"


Now at command line, I am at C:\Program Files\.............\html\classes\com\MVCBasedForms>javac Version002\BeerSelect002Servlet.java
I am unable to compile and keep getting the following error

BeerSelect002Servlet.java:7: package com.MVCBasedForms.Version002.model does not exist
import com.MVCBasedForms.Version002.model.*;
^
BeerSelect002Servlet.java:26: cannot resolve symbol
symbol : class BeerExpert
location: class com.MVCBasedForms.Version002.BeerSelect002Servlet
BeerExpert be = new BeerExpert();
^
BeerSelect002Servlet.java:26: cannot resolve symbol
symbol : class BeerExpert
location: class com.MVCBasedForms.Version002.BeerSelect002Servlet
BeerExpert be = new BeerExpert();

I have tried variations of C:\Program Files\.............\html\classes\com\MVCBasedForms\Version002> javac BeerSelect002Servlet.java
But the compiler gives the same error. Eventhough I have placed the 2 Java Files to match the respective package statements, the compiler still does not recognize the com.MVCBasedForms.Version002.model package.

Thanks for your time and help.

Regards
Subir
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
Execute javac in C:\Program Files\.............\html\classes\ directory.

Daesung Park

BLOG
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

You need to set your classpath
And this question does not relate to JSP's , please choose an appropriate forum for your posts.


SCJP, SCWCD.
|Asking Good Questions|
Subir Mukherjee
Greenhorn

Joined: Jul 20, 2001
Posts: 10
Thank you All. Issue resolved - had to explicitly include under the classpath the location of where my java package was - the code compiled after that.

Yes Amit - my bad - the issue should have been under Java General and not JSPs.

Thank you
Subir
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Subir Mukherjee wrote:
Yes Amit - my bad - the issue should have been under Java General and not JSPs.


Wasn't bad at all, everyone makes mistakes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with compiling Java Files inside of Packages