• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Compiling java files in packages  RSS feed

 
Ameetha Junaina
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have a question in Java when compiling with packages. Can anyone Help??
My 2 java files BeerSelect2.java & BeerExpert.java are in packages com.example.web & com.example.model respectively. The root folders goes like this.
C:\MyProjects\beerV1\src\com\example\web\BeerSelect2.java
and
C:\MyProjects\beerV1\src\com\example\model\BeerExpert.java

I have compiled the BeerExpert.java in the model package.(ie the class file for BeerExpert is in the com.example.model package.)

My BeerSelect2 file which is inside the web folder is like this



This shows 3 comile errors.
& the BeerExpert.java file which is in the model folder is like this:

This compiles fine in the model folder.

Now in the above BeerSelect2.java program(Servlet)-- when I'm trying to compile my BeerSelect2.java in the 'web' folder in which I'm trying to import the com.example.model.* ;

ie In the Command Prompt:

C:\MyProjects\beerV1\src\com\example\web>javac BeerSelect2.java
gives 3 errors like this

BeerSelect2.java:3: package com.example.model does not exist
import com.example.model.*
^

BeerSelect2.java:22:cannot find symbol
symbol: class BeerExpert
location: class com.example.web.BeerSelect2.
BeerExpert be=new BeerExpert();
^

BeerSelect2.java:22:cannot find symbol
symbol: class BeerExpert
location: class com.example.web.BeerSelect2.
BeerExpert be=new BeerExpert();


Can anyone help???
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Please BeForthrightWhenCrossPostingToOtherSites
http://forums.oracle.com/forums/thread.jspa?threadID=1774800
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please avoid coloured text, which many find difficult to read. Please use the code button; since you are new I have edited your post and you can see how much better it looks.

Search these fora for "compiling packages" and you will find several old threads about similar problems, which will help you, but the simplest thing to do for a beginner's exercise is to //comment out the package names in all your classes and compile them in a folder, called the "unnamed package."
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!