• Post Reply Bookmark Topic Watch Topic
  • New Topic

import problems (package does not exist)  RSS feed

 
David Dickson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java bean called UserInfoBean:
[davidd@DAVIDD beans]$ ls /usr/jakarta-tomcat-4.1.27/webapps/cec/WEB-INF/classes/com/cec/beans/
UserInfoBean.java
and a utility class for verifying different types of Strings:
[davidd@DAVIDD beans]$ ls /usr/jakarta-tomcat-4.1.27/webapps/cec/WEB-INF/classes/com/cec/util/
StringFormat.class StringFormat.java
When I try to compile the bean (that imports the above package) I get the following error:
[davidd@DAVIDD beans]$ javac -classpath /usr/jakarta-tomcat-4.1.27/common/lib/servlet.jar UserInfoBean.java
UserInfoBean.java:3: package com.cec.util does not exist
import com.cec.util.StringFormat;
^
1 error
[davidd@DAVIDD beans]$ more /usr/jakarta-tomcat-4.1.27/webapps/cec/WEB-INF/classes/com/cec/util/StringFormat.java
package com.cec.util;
import java.text.*;
import java.util.*;
public class StringFormat {
...
}
[davidd@DAVIDD beans]$ more /usr/jakarta-tomcat-4.1.27/webapps/cec/WEB-INF/classes/com/cec/beans/UserInfoBean.java
package com.cec.beans;
import com.cec.util.StringFormat;
import java.io.*;
import java.util.*;

public class UserInfoBean implements Serializable{
private static String DATE_FORMAT_PATTERN = "yyyy-mm-dd";
private static String[] COUNTRY_LIST = {"ca", "mx", "us"};
private String firstName;
private String lastName;
...
}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Welcome to JavaRanch!
You wrote
javac -classpath /usr/jakarta-tomcat-4.1.27/common/lib/servlet.jar ...
That tells javac to look only in that jar file for other classes, which means it won't look in the right place to find your utilities. You'd need to say something like
javac -classpath /usr/jakarta-tomcat-4.1.27/common/lib/servlet.jar;/usr/jakarta-tomcat-4.1.27/webapps/cec/WEB-INF/classes/ ...
Now, obviously, this is an inhuman amount of typing. This is why people use build tools like make and Ant. But in any case, this should solve your immediate problem.
 
David Dickson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's exactly what the problem was! I figured it out moments before you posted your reply.
Dave
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!