当前位置: 代码迷 >> Java Web开发 >> 两个自定义的java包互相不能访问,甚至同一个包中的java文件相互之间也不能 ...
  详细解决方案

两个自定义的java包互相不能访问,甚至同一个包中的java文件相互之间也不能 ...

热度:350   发布时间:2010-02-12 09:00:38.0
两个自定义的java包互相不能访问,甚至同一个包中的java文件相互之间也不能调用。
自定义的两个java包互相不能访问,甚至同一个包中的java文件相互之间也不能调用。

请问是  什么问题,应该怎么解决?

我的环境变量:
classpath :.;D:\Java\jdk1.6.0_18\lib\tools.jar;D:\Java\jdk1.6.0_18\lib\dt.jar

  JAVA_HOME : D:\Java\jdk1.6.0_18

  Path : D:\Java\jdk1.6.0_18\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Microsoft SQL Server\80\Tools\BINN


  然后我定义的两个包的路径是:

  C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes
  的下面,一个是  comm 文件夹,一个是  Information  文件夹。

  但是 当浏览器的地址栏输入 http://localhost:9090/myapp/index.jsp  时,就说找不到
Information 和 comm 中的 类 。

  请问这到底怎么解决呢?????
搜索更多相关主题的帖子: java  访问  文件  定义  相互之间  

----------------解决方案--------------------------------------------------------
异常信息如下:
异常信息如下:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 42 in the jsp file: /admin/InfoComm.jsp
User cannot be resolved to a type
39: public String getName(String Userid)throws Exception
40: {
41:   try{
42: User o_user = new User();
43: o_user.setUserId(Userid);
44: if(o_user.getUser())
45:   {


An error occurred at line: 30 in the jsp file: /left.jsp
Categories cannot be resolved to a type
27: //如果是管理员,则可以设置用户信息,如果是其他用户则可以更改自己的密码
28: // 定义用户对象
29: Vector v_Cate = new Vector();
30: Categories o_Cate = new Categories();
31: v_Cate = o_Cate.getMoreCategories();
32: for(int i=0;i <v_Cate.size();i++)
33: {


An error occurred at line: 30 in the jsp file: /left.jsp
Categories cannot be resolved to a type
27: //如果是管理员,则可以设置用户信息,如果是其他用户则可以更改自己的密码
28: // 定义用户对象
29: Vector v_Cate = new Vector();
30: Categories o_Cate = new Categories();
31: v_Cate = o_Cate.getMoreCategories();
32: for(int i=0;i <v_Cate.size();i++)
33: {


An error occurred at line: 34 in the jsp file: /left.jsp
Categories cannot be resolved to a type
31: v_Cate = o_Cate.getMoreCategories();
32: for(int i=0;i <v_Cate.size();i++)
33: {
34: o_Cate = (Categories)v_Cate.elementAt(i);
35: %>
36: <tr> <td align="center"> <a href="infoList.jsp?cid= <%=o_Cate.getCateId()%>" target="main" style="text-decoration: none"> <%=o_Cate.getCateTitle()%> </a> </td> </tr>
37: <% }%>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:319)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.28
----------------解决方案--------------------------------------------------------
我在Jcreator中编译User.java时,出现的错误信息如下:

--------------------Configuration: JDK version 1.6.0_18 <Default>--------------------
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:8: 软件包 comm 不存在
import comm.*;
^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:17: 找不到符号
符号: 类 StringOper
位置: 类 Information.User
    StringOper so = new StringOper();
    ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:17: 找不到符号
符号: 类 StringOper
位置: 类 Information.User
    StringOper so = new StringOper();
                        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:23: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:23: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:77: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:77: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:140: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:140: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:160: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:160: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:182: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:182: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:204: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
        ^
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java:204: 找不到符号
符号: 类 DBOper
位置: 类 Information.User
        DBOper o_DBOper = new DBOper();
                              ^
注意:C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myapp\WEB-INF\classes\Information\User.java 使用了未经检查或不安全的操作。
注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
15 错误

Process completed.


----------------解决方案--------------------------------------------------------
问题有点模糊,你可以截取一个包结构图来看看,说不定可以帮你解决。
----------------解决方案--------------------------------------------------------
请问你是在什么编译器中编译的?先试试在dos下编译看看能不能行,用简单的代码试试你的环境配置是不是正确。
----------------解决方案--------------------------------------------------------
  相关解决方案