Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to identify a package - Identified ;-)  RSS feed

 
R Sriram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have organized my code into packages, but , When I try to import a package that I created, the compiler throws a package *** does not exist error.
Pl find below my directory structure.
testwebapp - Level 1
-->WEB-INF - Level 2
------->src - Level 3
----------->com - Level 4
------------------>game - Level 5
-------------------------->web - Level 6
--------------------------------->mainServlet.java - Level 7
-------------------------->model - Level 6
--------------------------------->status.java - Level 7
------->classes - Level 3
----------->com - Level 4
------------------>game - Level 5
-------------------------->web - Level 6
-------------------------->model - Level 6
--------------------------------->status.class - Level 7
I have set the classpath for the servlet-api.jar. From the command prompt, I moved to the WEB-INF directory and then from there when I tried to execute the following command, I get the package not found error
javac -d classes src\com\game\web\mainServlet.java.
More importantly note that I am importing the "status.java" in the "mainServlet.java".
Any help would be very useful.

[ August 03, 2008: Message edited by: R Sriram ]

[ August 03, 2008: Message edited by: R Sriram ]
[ August 03, 2008: Message edited by: R Sriram ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which package isn't found? Post the complete error message.

In which directory is "status.class"? In which package is it?
[ August 03, 2008: Message edited by: Ulf Dittmer ]
 
R Sriram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,
I have edited my first post to answer your question.
Thanks a lot. I just found out that I was doing a very small mistake.
I was compiling from a directory which was one level above the exact replica in the classes directory structure as well.
If you see my post(previous) I was trying to compile from WEB-INF and then using the below command
javac -d classes src\com\game\web\mainServlet.java

Instead, the correct way would be to complie from WEB-INF\src\ directory and the command below
javac -d ..\classes com\game\web\mainServlet.java since the italicized one is the actual package structure which the compiler will try to replicate inside the directory specified.

Hope I am correct.
Thanks a tonne for the interest shown.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!