Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的代码可以与Eclipse一起工作,但无法使用javac-JDK7进行编译_Java_Eclipse_Ant - Fatal编程技术网

我的代码可以与Eclipse一起工作,但无法使用javac-JDK7进行编译

我的代码可以与Eclipse一起工作,但无法使用javac-JDK7进行编译,java,eclipse,ant,Java,Eclipse,Ant,我的代码在Eclipse中编译并运行良好。我还出口了.jar。但当我用ant和javac在构建服务器上编译它时,它会给出错误消息,无法编译 这是在我将JList更改为JList后发生的。我更改了它,因为有人说通用原始类型不安全 我应该再次使用原始类型吗?还是有别的想法 服务器中javac的版本是1.7.0_72,我的eclipse版本是4.4.1 我的代码: public class CheckListManager extends MouseAdapter implements ListSe

我的代码在Eclipse中编译并运行良好。我还出口了.jar。但当我用ant和javac在构建服务器上编译它时,它会给出错误消息,无法编译

这是在我将
JList
更改为
JList
后发生的。我更改了它,因为有人说通用原始类型不安全

我应该再次使用原始类型吗?还是有别的想法

服务器中javac的版本是1.7.0_72,我的eclipse版本是4.4.1

我的代码:

public class CheckListManager  extends MouseAdapter implements ListSelectionListener, ActionListener{ 
    private ListSelectionModel selectionModel = new DefaultListSelectionModel(); 
    private JList<Object> list = new JList<Object>();
    int hotspot = new JCheckBox().getPreferredSize().width; 

    public CheckListManager(JList<Object> list) {
        this.list = list; 
        list.setCellRenderer(new CheckListCellRenderer(list.getCellRenderer(), selectionModel)); 
        list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED); 
        list.addMouseListener(this); 
        selectionModel.addListSelectionListener(this); 
    }

    (... so on)

    private class CheckListCellRenderer extends JPanel implements ListCellRenderer<Object> {
        public CheckListCellRenderer(ListCellRenderer<Object> renderer, ListSelectionModel selectionModel) {

        (...)

        }
    }
}
public类CheckListManager扩展MouseAdapter实现ListSelectionListener,ActionListener{
private ListSelectionModel selectionModel=新的默认ListSelectionModel();
私有JList list=新JList();
int hospot=new JCheckBox().getPreferredSize().width;
公共CheckListManager(JList列表){
this.list=列表;
setCellRenderer(新的CheckListCellRenderer(list.getCellRenderer(),selectionModel));
list.registerKeyboardAction(这个,KeyStroke.getKeyStroke(KeyEvent.VK_SPACE,0),JComponent.WHEN_FOCUSED);
list.addMouseListener(本);
selectionModel.addListSelectionListener(此);
}
(……等等)
私有类CheckListCellRenderer扩展JPanel实现ListCellRenderer{
公共CheckListCellRenderer(ListCellRenderer渲染器,ListSelectionModel selectionModel){
(...)
}
}
}
错误代码:

C:\BuildSite_United\trunk\java\XE Core\src\com\psia\core\view\util\CheckListManager.java:29: error: constructor CheckListCellRenderer in class CheckListManager.CheckListCellRenderer cannot be applied to given types;
        list.setCellRenderer(new CheckListCellRenderer(list.getCellRenderer(), selectionModel));
                             ^
  required: ListCellRenderer<Object>,ListSelectionModel
  found: ListCellRenderer<CAP#1>,ListSelectionModel
  reason: actual argument ListCellRenderer<CAP#1> cannot be converted to ListCellRenderer<Object> by method invocation conversion
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object super: Object from capture of ? super Object
C:\BuildSite\u United\trunk\java\XE Core\src\com\psia\Core\view\util\CheckListManager.java:29:错误:CheckListManager.CheckListCellRenderer类中的构造函数CheckListCellRenderer不能应用于给定类型;
setCellRenderer(新的CheckListCellRenderer(list.getCellRenderer(),selectionModel));
^
必需:ListCellRenderer、ListSelectionModel
找到:ListCellRenderer,ListSelectionModel
原因:无法通过方法调用转换将实际参数ListCellRenderer转换为ListCellRenderer
其中CAP#1是一个新类型变量:
CAP#1扩展了Object super:从捕获到的对象?超级对象

您在eclipse中使用的Java版本是什么?如果您的应用程序基于SWT、JFACE或其他。JDK中没有相关的库。Elliott Frisch//javac是1.7.0_72,eclipse是4.4.1CHmoonKa//。大约1周前。您的构建服务器上运行的是什么版本的java?是否小于1.5?您可以使用命令“java-version”检查版本。确认脚本使用的路径仍然与JDK 7相同。因为您的服务器上可能有多个版本。