我有这段代码:
public static void main (String[] args) {
Config c;// = null;
try {
c = new Config();
} catch (Exception e) {
System.err.println("Error while parsing/reading file: " + e.getMessage());
System.exit(-1);
}
final NetworkReporter np = new NetworkReporter(c.getValues().serverIP, c.getValues().serverPort, (short)(c.getValues().checkInterval * c.getValues().checksPerReport));
IdleChecker idleChecker = new IdleChecker(c.getValues().checkInterval, c.getValues().checksPerReport, c.getValues().idleSensitivity, new IdleChecker.reportFunction() {
public void report() {
np.report();
}
});
idleChecker.start();
}
当我编译这段代码时,我得到:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project FanstisTime: Compilation failure
[ERROR] /home/amitg/Programming/Projects/FantisTime/FantisTime/src/main/java/com/amitg/fantistimeclient/Client.java:[13,54] variable c might not have been initialized
我确实理解这意味着什么,事实上 - 它将始终被初始化(因为如果无法初始化,程序将退出)。我必须在那里尝试捕获,因为会引发一些异常。我尝试在那里使用,它给了我这个:variable c might not have been initializenew Config()Config c = null;
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project FanstisTime: An exception occured while executing the Java class. null: NullPointerException -> [Help 1]
你知道我能做些什么来解决这个问题吗?谢谢!
慕侠2389804
海绵宝宝撒
扬帆大鱼
相关分类