Eclipse环境下a class file was not written问题的解决办法

来源:互联网 发布:手机赚钱软件哪个好 编辑:程序博客网 时间:2024/05/22 14:09

今天在学java泛型的课程,敲了以下代码后发现编译出错,提示A class file was not written. The project may be inconsistent, if so try refreshing this project and building it.

package com.generic;class Con<T>{private T value;public Con(T v){this.value = v;}public T getValue() {return value;}public void setValue(T value) {this.value = value;}}public class Test2 {public static void main(String[] args) {// TODO Auto-generated method stubCon<String> c = new Con<String>("this is a string");System.out.println(c.getValue());}}

查找了一些资料,说是workspace所在磁盘空间不足引起的,我看了下磁盘空间足够大,所以排除,后来发现CSDN上一位zhtao0416兄弟发现了一个解决方案,试了下果然可以,以下内容来自http://blog.csdn.net/zhtao0416/article/details/4256217   侵删。

下面是其他的一些保留字,在Windows下面都不能创建。注重,不许分大小写。Con,con,CON 都不可以! 

con是操作系统保留的一个设备名字,还有很多设备名都不能拿来用,如下: 

The following reserved device names cannot be used as the name of a file: CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed by an extension (for example, NUL.tx7).

把代码中所有的Con换成Cons以后问题迎刃而解。

1 0
原创粉丝点击