餐巾的外观和感觉
我添加了餐巾库和此代码
try {
UIManager.setLookAndFeel("net.sourceforge.napkinlaf.NapkinLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
,但我不断收到此异常:
java.lang.ClassNotFoundException: net.sourceforge.napkinlaf.NapkinLookAndFeel
i added napkin library and this code
try {
UIManager.setLookAndFeel("net.sourceforge.napkinlaf.NapkinLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
but i keep getting this exception :
java.lang.ClassNotFoundException:
net.sourceforge.napkinlaf.NapkinLookAndFeel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要确保带有该类的 jar 在运行时位于您的类路径中。
You need to make sure the jar with that class is on your classpath at runtime.
在运行时,餐巾库可能不在应用程序的类路径中。
运行程序时,检查您在命令行中指定的“-cp”参数。
您所说的“添加库”可能意味着仅将其添加到编译时类路径中;由于使用了类的名称,我猜实际的类是在运行时动态加载的。因此 JVM 必须指示哪个 jar 包含该类的字节码。
The napkin library is probably not in the classpath of your application, at runtime.
Check what you've specified as the '-cp' argument of your command line, when running the program.
What you mean by 'adding the library' probably means only adding it to the compile-time classpath ; since the name of the class is used, I guess the actual class is loaded dynamically at runtime. So the JVM must have an indication of which jar contains the bytecode for the class.
您使用的是 Eclipse 还是其他 IDE?如果是这样,您需要在构建设置中添加依赖项/jar 文件。在 Eclipse 中,您只需右键单击并在“构建路径”(我相信)下选择“添加到构建路径”。
否则,当您在命令行上启动Java时,您需要列出依赖的jar文件。这是一种方法:
java -classpath yourjar.jar;napkinlaf.jar yourpackage.YourMainClass
(当然,您必须适当地自定义该命令行。这也假设您正在为应用程序构建一个 jar 文件。 .)
Are you using Eclipse or some IDE? If so you need to add the dependency/jar file in the build settings. In Eclipse you can just right-click and under Build Path (I believe) select "Add to Build Path".
Otherwise you need to list the dependent jar file when you start Java on the command line. This is one way:
java -classpath yourjar.jar;napkinlaf.jar yourpackage.YourMainClass
(You'd have to customize that command line appropriately of course. This is also assuming you're building a jar file for your application...)
确保下载正确版本的餐巾外观。
不幸的是,当前 SourceForge 项目首页上的版本是 alpha001 版本,它实际上将类放置在
napkin
包中。要使用它,您需要执行以下操作:但是您应该转到中的“文件”选项卡SourceForge 项目并浏览以查找最新版本。
Make sure that you download the correct version of the Napkin Look and Feel.
The version currently on the front page of the SourceForge project is unfortunately the alpha001 version which actually has the classes placed in the
napkin
package. To use it you need to do the following:But instead you should go to the "Files" tab in the SourceForge project and browse to find the latest release.