解决:The declared package..does not match the expected package..(转自百度空间)
来源:互联网 发布:ubuntu显示所有用户 编辑:程序博客网 时间:2024/05/17 21:53
包名必须在程序中通过package语句来指定(例如 package org.it),而不是单纯的靠目录结构来指定,是先有了包名之后,才需要相应的目录结构。这是实际上的类名为org.it315.classname。必须把包声明放在源文件最前面,并且每个源文件最多只能声明一个包(最好要声明包,养成良好的编码风格和习惯)。
如以下文件:
TestPackage.java
package org.it;
public class TestPackage
{
public static void main(String[] args)
{
System.out.println("Test use package");
}
}
假设其位于目录是:E:/eclipse/webEclipse/testproject/src/org/it
在dos下直接进行:
编译: E:/eclipse/webEclipse/testproject/src/org/it>javac TestPackage生成TestPackage.class文件位于E:/eclipse/webEclipse/testproject/src/org/it/目录下。
运行: E:/eclipse/webEclipse/testproject/src>java org.it.TestPackage得到正确输出结果。
一定要注意此处路径问题。另外,package的名字和结构必须和相关的目录名一致,包括大小写也要一致。但是在Eclipse中,由于一般是先新建包,eclipse创建package的时候自动帮你创建了目录了,所以不会不一致。Eclipse会在对应testproject/bin目录下生成org/it/目录,并且在org/it/目录下生成TestPackage.class文件,但是实际上此class的名称为org.it.TestPackage.class。当然,在Eclipse中可以直接运行,但是在dos命令下,一定要注意实质上的编译和运行实际路径和类名等问题。
解决:
Access restriction : The type BASE64Decoder is not accessible due to restriction
Access restriction : The type BASE64Decoder is not accessible due to restriction on required library C:\Program
files\java\jre6\lib\rt.jar
Access restriction : The constructor BASE64Decoder() is not accessible due to restriction on required library C:\Program files\java\jre6\lib\rt.jar
解决方案1(推荐):
只需要在project build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了。
解决方案2:
Windows -> Preferences -> Java -> Compiler -> Errors/Warnings ->
Deprecated and trstricted API -> Forbidden reference (access rules): -> change to warning
Volatile修饰的成员变量在每次被线程访问时,都强迫从共享内存中重读该成员变量的值。而且,当成员变量发生变化时,强迫线程将变化值回写到共享内存。这样在任何时刻,两个不同的线程总是看到某个成员变量的同一个值。Java语言规范中指出:为了获得最佳速度,允许线程保存共享成员变量的私有拷贝,而且只当线程进入或者离开同步代码块时才与共享成员变量的原始值对比。这样当多个线程同时与某个对象交互时,就必须要注意到要让线程及时的得到共享成员变量的变化。而volatile关键字就是提示VM:对于这个成员变量不能保存它的私有拷贝,而应直接与共享成员变量交互。使用建议:在两个或者更多的线程访问的成员变量上使用volatile。当要访问的变量已在synchronized代码块中,或者为常量时,不必使用。由于使用volatile屏蔽掉了VM中必要的代码优化,所以在效率上比较低,因此一定在必要时才使用此关键字。 就跟C中的一样 禁止编译器进行优化~~~~
- 解决:The declared package..does not match the expected package..(转自百度空间)
- 解决:The declared package..does not match the expected package..
- The declared package "" does not match the expected package
- The declared package does not match the expected package
- The declared package "" does not match the expected package "javaControlSql"
- The declared package does not match the expected package
- The declared package does not match the expected package
- The declared package does not match the expected package
- The declared package..does not match the expected package
- Eclipse: The declared package does not match the expected package
- The declared package does not match the expected package
- The declared package "com.XXX" does not match the expected package ""
- The declared package "com.dao" does not match the expected package "src.com.dao"
- The declared package "com.XXX" does not match the expected package ""
- JDBC产生The declared package does not match the expected package
- eclipse 中导入源码出现 The declared package does not match the expected package的解决方法
- the declared package does not match 解决办法
- 从SVN上检出Maven项目报红叉错误,package错误 does not match the expected package "main.java.com.*
- J2EE项目从MyEclipse迁移到Eclipse
- ASP.NET后台实现网站打开和关闭功能
- 权限照抄要小心
- Debian中的硬件模拟器
- HOWTO Install Ceph On FC12, FC上安装Ceph分布式文件系统
- 解决:The declared package..does not match the expected package..(转自百度空间)
- 俞敏洪老师的联系方式
- CFLAGS in Makefile
- 仿谷歌,百度分页 计算分析
- List排序及与String的转换
- Com与Dcom、Com+、Ole、ActiveX 的关系
- glTranslatef(0.0f,-20.0f,-40.0f)表示将当前图形向x轴平移0,向y轴平移-20,向z轴平移-40 glScaled(10.0f,10.0f,10.0f)表示将当前图形沿x,y,z轴分别放大为原来的10倍 glRotatef(-
- 在新浪,在新浪
- 购物兔终于出来了,一款垂直领域的购物浏览器!