简体   繁体   English

Netbeans 上的 NoClassDefFoundError 但在命令行上运行

[英]NoClassDefFoundError on Netbeans but runs on command line

I am trying to run a hello world java program on Netbeans but its giving me the following error:我正在尝试在 Netbeans 上运行 hello world java 程序,但它给了我以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

I compiled and ran it on Command line and it worked.我在命令行上编译并运行它并且它工作。 Then, I went back to Netbeans and I ran it again..this time it worked (because HelloWorld.class file is under the src folder).然后,我回到 Netbeans 并再次运行它。这次它成功了(因为 HelloWorld.class 文件位于 src 文件夹下)。 After deleting the.class file from the folder, it did not run again on Netbeans.从文件夹中删除 .class 文件后,它没有在 Netbeans 上再次运行。

It is something to do with Netbeans but I can't seem to figure out what would fix this issue.这与 Netbeans 有关,但我似乎无法弄清楚什么可以解决这个问题。 I checked under project properties -> Libraries -> and the java platform is set to JDK 1.6我在项目属性 -> 库 -> 下检查了 java 平台设置为 JDK 1.6

I am using Netbeans 7.0 on Mac.我在 Mac 上使用 Netbeans 7.0。

Please help me out:(请帮帮我:(

NetBeans is running.class file not.jar when you run project. NetBeans 正在运行。class 文件不是。jar 运行项目时。 Usually it runs.class from build/classes directory.通常它从 build/classes 目录运行.class。 If you provide description of your project structure (or even screenshod) we could tell more.如果您提供项目结构的描述(甚至是屏幕截图),我们可以提供更多信息。 Here is detailed tutorial how to create and run Hello World app in NetBeans . 这是如何在 NetBeans 中创建和运行 Hello World 应用程序的详细教程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 代码可以在Netbeans中编译并运行,但不能在Java命令行中运行 - Code compiles and runs in Netbeans but not java command line Java项目在netbeans中运行,但不能从命令行运行 - Java project runs in netbeans but not from command line 在Netbeans中,程序运行顺利,在命令行中我得到一个JavaNoClassDefFoundError - In Netbeans the program runs smoothly, in command line I get a JavaNoClassDefFoundError 命令行中的Java NoClassDefFoundError - Java NoClassDefFoundError in Command Line Java命令行中的NoClassDefFoundError - NoClassDefFoundError in java command line 在netbeans中正常运行,但在命令提示符下无法正常运行 - runs properly in netbeans but not in command prompt eclipse-maven项目-NoClassDefFoundError从eclipse运行,但从命令行运行良好 - eclipse-maven project - NoClassDefFoundError running from eclipse but runs fine from command line 项目在Eclipse中运行,但不是从命令行运行:带有Maven和Dom4J的java.lang.NoClassDefFoundError - Project runs in Eclipse, but not from command line : java.lang.NoClassDefFoundError with Maven and Dom4J 使用Apache procrun接收NoClassDefFoundError(Eclipse生成的jar),但在命令行上运行良好 - Receiving a NoClassDefFoundError (Eclipse generated jar) using Apache procrun but runs fine on command line java项目从命令行运行良好,但从NetBeans运行时会抛出异常 - A java project runs well from the command line, but it throws an exception when run from NetBeans
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM