• Post Reply Bookmark Topic Watch Topic
  • New Topic

Package doesn't exists while compiling servlet  RSS feed

 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to print records of all employees from employeeinfo table.
I have three packages.
package db contains EmpRecords.class which returns ResultSet object with set of all employee records.
package emprecords contains ShowEmpRecords.class which is a servlet which just prints these records in table using html tags.

Location of all packages I've created except lib:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes\
Location of lib directory:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\lib\servlet-api.jar
EmpRecords.class file:
Location: C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes\db\EmpRecords.class
EmpRecords.java code:


ShowEmpRecords.class file:
Location:C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes\emprecords\ShowEmpRecords.class
ShowEmpRecords.java code:


web.xml file:
Location:C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\web.xml
web.xml code:

How I compile both files:
EmpRecords.java:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes javac db\EmpRecords.java;

ShowEmpRecords.java:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes javac -classpath C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\lib\servlet-api.jar emprecords\ShowEmpRecords.java

Problem: Why it gives error on line 18 of ShowEmpRecords.java i.e. package db does not exist ?
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at your classpath; which part of it refers to the parent of that "db" directory?

By the way you'll need to put quotes around path names and file names containing spaces, so that the Windows shell handles them properly. Remember that spaces are normally used by the shell as separators.
 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at your classpath; which part of it refers to the parent of that "db" directory?
Do you mean do I also have to add location of db directory in classpath along with directory location of servlet-api.jar ?
 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Paul, It worked, now I can have sound sleep
I compiled EmpRecords.java like this
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes javac db\EmpRecords.java

Compiled ShowEmpRecords.java
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\classes javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\EmployeeRecords\WEB-INF\lib\servlet-api.jar"; "db\EmpRecords.java" emprecords\ShowEmpRecords.java

Do I need to make any improvement in above way of compilation?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!