Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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
Java Eclipse:控制台上的IProcess输出_Java_Eclipse_Plugins_Process_Eclipse Plugin - Fatal编程技术网

Java Eclipse:控制台上的IProcess输出

Java Eclipse:控制台上的IProcess输出,java,eclipse,plugins,process,eclipse-plugin,Java,Eclipse,Plugins,Process,Eclipse Plugin,我尝试写入控制台时遇到问题 在插件项目中,我开发了一个自定义构建,可以使用我开发的命令通过菜单调用它。最初,构建是在实现ILaunchConfigurationDelegate的类的launch方法中调用的 ... String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]); Process compilerProcess = DebugPlugin

我尝试写入控制台时遇到问题

在插件项目中,我开发了一个自定义构建,可以使用我开发的命令通过菜单调用它。最初,构建是在实现ILaunchConfigurationDelegate的类的
launch
方法中调用的

...
        String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
        Process compilerProcess = DebugPlugin.exec(commandLine, new File(project.getLocation().toString()));

        @SuppressWarnings("rawtypes")
        Map processAttributes = new HashMap();
        processAttributes.put(IProcess.ATTR_PROCESS_TYPE, "XVR");
        IProcess dbgProcess = DebugPlugin.newProcess(launch, compilerProcess, "XVR Compiler", processAttributes);

        try {
            compilerProcess.waitFor();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        if(compilerProcess.exitValue() != 0) return false;
        launch.removeProcess(dbgProcess); 
执行构建时,进程的输出将打印在控制台上,并使用实现IConsoleLineTracker的类进行解析,以突出显示错误

我将build方法移到实现ILaunchConfigurationDelegate的类之外,控制台不再打印。这两种情况之间的唯一区别是如何提供对象iLaunch。新的构建方法如下

   ...
String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
    Process compilerProcess = DebugPlugin.exec(commandLine, new File(prj.getLocation().toString()));

    ILaunch xvrLaunch = XVRUtils.getXVRLaunch();
    Map<String, String> processAttributes = new HashMap<String, String>();
    processAttributes.put(IProcess.ATTR_PROCESS_TYPE, "XVR");

    IProcess dbgProcess = DebugPlugin.newProcess(xvrLaunch, compilerProcess, "XVR Compiler", processAttributes);

    try {
        compilerProcess.waitFor();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if(compilerProcess.exitValue() != 0)
        return false;
    xvrLaunch.removeProcess(dbgProcess);
为什么进程不再在控制台上打印


谢谢

日志中是否有异常?是否从(直接或间接)实现ILaunchConfigurationDelegate.launch()的类调用build()方法?Close vote。也没有描述所需的输出,也没有明确指出应该产生输出的代码。
public static ILaunch getXVRLaunh(){
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    if(launches.length > 0){
        for (ILaunch launch : launches) {
            ILaunchConfiguration conf = launch.getLaunchConfiguration();
            try {
                if(conf.getType().equals(manager.getLaunchConfigurationType(ApplicationLaunchConfigurationDelegate.XVR_LAUNCH_CONFIGURATION_ID)))
                    return launch;
            } catch (CoreException e) {
                e.printStackTrace();
            }
        }

    }
    ILaunchConfiguration config = getXVRLaunchConfiguration();
    Launch l = new Launch(config, "run, debug", null);
    l.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, null);
    try {
        if (l.getSourceLocator() == null) {
            String type;
            type = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);

            if (type == null) {
                type = config.getType().getSourceLocatorId();
            }
            if (type != null) {
                IPersistableSourceLocator locator = manager.newSourceLocator(type);
                String memento = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
                if (memento == null) {
                    locator.initializeDefaults(config);
                } else {
                    if(locator instanceof IPersistableSourceLocator2)
                        ((IPersistableSourceLocator2)locator).initializeFromMemento(memento, config);
                    else
                        locator.initializeFromMemento(memento);
                }
                l.setSourceLocator(locator);
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return l;
}