- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
public class Main {
public static void main(String... strings) throws IOException {
try {
String path = "E:\\Java\\Projects\\.metadata\\.plugins\\org.eclipse.debug.core\\.launches\\MedicineFrame.launch";
ILaunchManager launchManager = DebugPlugin.getDefault()
.getLaunchManager();
ILaunchConfigurationType type = launchManager
.getLaunchConfigurationType(ILaunchManager.RUN_MODE);
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(
null, path);
workingCopy.setAttribute("PATH_MY", path);
ILaunchConfiguration configuration = workingCopy.doSave();
DebugUITools.launch(configuration, ILaunchManager.RUN_MODE);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
其实我只是想运行绝对路径定义的文件中指定的启动配置。我收到 NPE,因为 DebugPlugin.getDefault() 返回 null。我应该怎么办?我发现了很多类似的例子,但没有一个是关于 NPE 的,就像在我之前没有人得到过它一样。
最佳答案
快速浏览 DebugPlugin 后 code我发现 DebugPlugin#getDefault()
方法是对 fgDefaultPlugin
字段的简单获取,并返回默认为 null
的字段值。由于您正在调用 DebugPlugin#getDefault()
作为 main
函数的第一个方法,因此它返回 null
是合理的,因为 DebugPlugin#setDefault()
之前未被调用。
您不能从这样的 main 方法运行 Eclipse。您需要编写一个插件,并且可以从插件方法内部访问它。
关于java - DebugPlugin.getDefault() 中的 NPE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14591339/
我正在使用 this stackOverflow post 中的代码,这符合我的预期: Enumeration keys = UIManager.getDefaults().keys();
我经常使用 TimeZone.getDefault 调用,我收到了来自客户的关于运行缓慢的报告。使用 jstack 检查线程堆栈跟踪,我看到许多线程被此方法阻塞: "LoadBalancerClien
package com.soft.mash.contactmanager; import android.app.Activity; import android.os.Bundle; import
当我运行以下行时, System.out.println(java.util.TimeZone.getDefault()); 我得到了以下输出。 sun.util.calendar.Zon
这个硬编码的 GMT+2 很有魅力。 calendarCurrent.setTimeZone(TimeZone.getTimeZone("GTM+2")); 当然我不需要硬编码,所以我正在使用 cal
My server is in US and I am accessing the application in India through web browser, in that case wha
目前我的系统区域设置是en-UK,它曾经是en-US(我已经重新启动了我的电脑以使这个更改生效) 当我打印 Locale.getDefault().getCountry().toString() 时,
最近开始学习 kotlin 编程语言的 android 系统编程。在编写用于从应用程序本身发送 SMS 的简单应用程序时,我遇到了 SmsManager.getDefault() 现在已弃用的问题,因
我有以下代码: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import
我有一个非常简单的代码: public static void main(String[] arg){ FileSystems.getDefault(); } 在Java7中运行良好 但抛出
我正在使用 eclipse 的作业 API 将大任务作为作业运行,一旦任务完成,我将 boolean 变量设置为 true,如果该变量为 true,我将在 UI 线程中执行 WizardDialog。
我正在使用 TimeZone.getDefault() 设置 Calendar 类的时区: Calendar cal = Calendar.getInstance(TimeZone.getDefaul
unix 机器上的服务器总是使用 en 作为默认语言环境。以下是语言环境输出 LANG=en_US LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_CO
本文整理了Java中xdi2.core.io.XDIReaderRegistry.getDefault()方法的一些代码示例,展示了XDIReaderRegistry.getDefault()的具体用
本文整理了Java中xdi2.core.io.XDIWriterRegistry.getDefault()方法的一些代码示例,展示了XDIWriterRegistry.getDefault()的具体用
即使将所有 SWT 代码包装在“Display.getDefault().asyncExec”中,我也无法更新我的 UI。 假设我有一个监听器,称为单击一个按钮。 Listener enterlisn
我的应用程序中有一个广播接收器,它会在设备的区域设置更改时被调用。我的应用程序在一些设备上存在错误,特别是 Nexus 5x 和 Galaxy S8+(很可能还有其他设备),其中 Locale.get
如果查找返回 null 该怎么办?我正在使用 org.openide.util.Lookup 的 Lookup.getDefault().lookup() ,它用于查找对象的实例。一般模式是传递一个
我在导入我的项目时在 eclipse 中遇到上述错误。我已经在 java 构建路径中添加了 jsse jar。错误代码为 var = SSLContext.getDefault().getSocket
我们有一个案例,其中运行使用 1.8.0_092 的 Java 8 应用程序的 PC 从 Locale.getDefault() 返回 null。虽然处理这个很简单,但我更担心返回 null,因为 d
我是一名优秀的程序员,十分优秀!