• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with compiling Java Files inside of Packages

 
Subir Mukherjee
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Execute javac in C:\Program Files\.............\html\classes\ directory.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set your classpath
And this question does not relate to JSP's , please choose an appropriate forum for your posts.
 
Subir Mukherjee
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic