• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue with compiling Java Files inside of Packages

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic