javac main.java 编译后没有问题

java main 出现下面在问题:

Exception in thread "main" java.lang.NoClassDefFoundError: main (wrong name: pm/main)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

解决方法:

  要加上类的包名才可以、还要注意你当所在位置;

  例如main.java的物理路径:A文件夹->AA文件夹->packname(也是文件夹)->main.java

  #cd /A文件夹/AA文件夹/packname

  #javac main.java

  OK这里没有问题。但是要执行java main是要返到类包名的上级目录才可以

  也就是物必须返回到"AA文件夹"目录

  然后:java packname.main 才能成功

  

可参见:http://blog.csdn.net/xifeijian/article/details/8831916

java Exception in thread "main" java.lang.NoClassDefFoundError: main (wrong name: pm/main)的更多相关文章

  1. Java中线程出现Exception in thread "Thread-0" java.lang.IllegalMonitorStateException异常 解决方法

    代码 package thread; public class TestChongNeng { public static void main(String[] args) { Thread t1 = ...

  2. Exception in thread "http-bio-8081-exec-3" java.lang.OutOfMemoryError: PermGen space

    前言: 在http://www.cnblogs.com/wql025/p/4865673.html一文中我曾描述这种异常也提供了解决方式,但效果不太理想,现在用本文的方式,效果显著. 目前此项目只能登 ...

  3. Exception in thread "http-apr-8080-exec-6" java.lang.OutOfMemoryError: PermGen space 解决!

    Exception in thread "http-apr-8080-exec-6" java.lang.OutOfMemoryError: PermGen space at ja ...

  4. 异常Exception in thread "AWT-EventQueue-XX" java.lang.StackOverflowError

    今天太背了,bug不断,检查到最后都会发现自己脑残了,粗心写错,更悲剧的是写错的时候还不提示错. 刚才有遇到一个问题,抛了这个异常Exception in thread "AWT-Event ...

  5. web 环境项目(intellj部署的tomcat) 重启时报 Exception in thread "HouseKeeper" java.lang.NullPointerException (转)

    Exception in thread "HouseKeeper" java.lang.NullPointerException at org.logicalcobwebs.pro ...

  6. exception in thread "http-apr-80-exec-24" java.lang.OutOfMemoryError:PermGen...

    今天客户说项目访问不了了,我急忙看了下告警,发现上报:“exception in thread "http-apr-80-exec-24" java.lang.OutOfMemor ...

  7. idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space

    idea Exception in thread "http-apr-8080-exec-2" java.lang.OutOfMemoryError: PermGen space ...

  8. 项目启动时 Exception in thread "HouseKeeper" java.lang.NullPointerException

    首先查看是否是端口冲突引起,在日志信息该错误位置往上找,如果再无错误信息,而只有该错误,则原因可能如下: 原因: This is because Proxool is not being shutdo ...

  9. Exception in thread "http-apr-8080-exec-1" java.lang.StackOverflowError

    Exception in thread "http-apr-8080-exec-1" java.lang.StackOverflowError 可能执行了递归,陷入了死循环 如下我 ...

  10. Lein: Exception in thread "Thread-3" java.net.ConnectException: Connection refused

    leiningen Leiningen是你的主要工具, 它用于: 启动一个 REPL 下载+安装类库 运行你的程序 启动一个服务器, 运行你所写的webapps 安装 brew install lei ...

随机推荐

  1. 好久没玩laravel了,5.6玩下(二)

    做个项目的增删改查 第一步  把数据库的表结构建好,生成迁移 1 怎么建,当然是用php artisan命令了 使用 Artisan 命令 make:migration 来创建一个新的迁移: php ...

  2. AES 加密256位 错误 java.security.InvalidKeyException: Illegal key size or default parameters

    Java发布的运行环境包中的加解密有一定的限制.比如默认不允许256位密钥的AES加解密,解决方法就是修改策略文件. 官方网站提供了JCE无限制权限策略文件的下载: JDK8的下载地址: http:/ ...

  3. UI5-文档-4.23-Custom Formatters

    如果希望对数据模型的属性进行更复杂的格式化逻辑,还可以编写自定义格式化函数.现在我们将使用自定义格式化程序添加本地化状态,因为数据模型中的状态是一种相当技术性的格式. Preview A status ...

  4. java web 跨域

    服务器端解决跨域问题的三种方法   跨域是指html文件所在的服务器与ajax请求的服务器是不同的ip+port,例如: - ‘192.168.1.1:8080’ 与 ‘192.168.1.2:808 ...

  5. How to Pronounce UMBRELLA

    How to Pronounce UMBRELLA Share Tweet Share Tagged With: 3-Syllable When the weather is bad, you’ll ...

  6. Extending Conductor

    后端 导体提供了可插拔的后端.目前的实现使用Dynomite. 每个后端需要实现4个接口: //Store for workflow and task definitions com.netflix. ...

  7. 构造函数中的super和this的使用

    super用于调用父类构造函数的部分,其必须出现在构造函数的第一行.super在调用时第一件事就是去执行父类构造函数的部分,所执行的父类构造函数与super()括号中的参数相对应. this用于在一个 ...

  8. idea下maven项目打包

    近使用idea运行maven需要打包上传tomcat服务器.但是网上一直零零碎碎的....自己记录一下.以防后面忘记 1.idea中.file →Project Structure(快捷键Ctrl+S ...

  9. 等待时间,time.sleep()和implicitly_wait()

    在运行一个以前执行的过的功能时,报错了,不能执行了. 功能描述:通过导航,选择下拉项(发布职位功能),下面是审查的元素: 获取元素的代码: 尝试了用xpath去获取:driver.find_eleme ...

  10. hdoj1014 互质

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...