[英]How to fix a NullPointerException error when running a program with becker.jar as an external jar?
I am setting up a program for a class I am taking. 我正在为参加的课程设置程序。 All the code has been provided and I have configured everything into Eclipse.
提供了所有代码,并且我已将所有内容配置到Eclipse中。 I also had to use
becker.jar
as an external jar file in the Libraries -> Classpath. 我还必须在库-> Classpath
becker.jar
用作外部jar文件。 When I run the program an error occurs about a NullPointerException
. 当我运行程序时,发生关于
NullPointerException
的错误。
I already tried changing the becker.jar into the modulepath instead of classpath but then Eclipse cannot find the file. 我已经尝试过将becker.jar更改为modulepath而不是classpath,但是Eclipse无法找到该文件。 I also tried reinstalling
becker.jar
as well as redoing the entire setup for the project. 我还尝试了重新安装
becker.jar
以及为项目重做整个设置。
Here is the code I am trying to set up: 这是我要设置的代码:
import becker.robots.*;
/*
Starting Template:
This file was created in order to provide you with a pre made
'starter' program
*/
public class Starting_Template extends Object {
public static void main(String[] args) {
City toronto = new City();
Robot jo = new Robot(toronto, 3, 0, Direction.EAST, 0);
new Thing(toronto, 3, 2);
jo.move();
jo.turnLeft();
}
}
When running this error shows up: 运行时显示此错误:
Exception in thread "main" java.lang.NullPointerException
at java.desktop/sun.font.FontDesignMetrics.getDefaultFrc(FontDesignMetrics.java:158)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:279)
at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1183)
at java.desktop/javax.swing.JComponent.getFontMetrics(JComponent.java:1646)
at java.desktop/javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:245)
at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
at java.desktop/javax.swing.JSlider.updateLabelUIs(JSlider.java:853)
at java.desktop/javax.swing.JSlider.setLabelTable(JSlider.java:824)
at becker.robots.x.<init>(SourceFile:32)
at becker.robots.RobotUIComponents.<init>(SourceFile:87)
at becker.robots.RobotUIComponents.<init>(SourceFile:110)
at becker.robots.City.a(SourceFile:228)
at becker.robots.City.<init>(SourceFile:97)
at becker.robots.City.<init>(SourceFile:47)
at Starting_Template.main(Starting_Template.java:10)
This is a bug. 这是一个错误。 See for example https://issues.jboss.org/browse/PLANNER-255?_sscc=t - the becker.jar has nothing to do with it.
参见例如https://issues.jboss.org/browse/PLANNER-255?_sscc=t-becker.jar与它无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.