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. XMind8 安装

    参考:https://blog.csdn.net/qq_35911589/article/details/81901868 https://blog.csdn.net/Zjhao666/article ...

  2. eclipse xml 编码问题 “3 字节的 UTF-8 序列的字节 3 无效”

    原本项目没问题,git commit之后,突然报错 “3 字节的 UTF-8 序列的字节 3 无效” 尝试过改xml文件编码等,没成功.pom中设置属性,成功解决 <project.build. ...

  3. postgresql 的操作

    基本操作: \o /tmp/11.txt ,查询结果输出到文件 \d 查询table结构 \x 切换显示方式 postgresql中可以导出某个sql的执行结果到文件中,方法是在psql中首先执行\o ...

  4. linux 中特殊符号用法详解

    # 井号 (comments)#管理员  $普通用户 脚本中 #!/bin/bash   #!/bin/sh井号也常出现在一行的开头,或者位于完整指令之后,这类情况表示符号后面的是注解文字,不会被执行 ...

  5. MySQL高级-索引

    1.索引是什么 索引(Index)是帮助MySQL高效获取数据的数据结构.可以得到索引的本质:索引是数据结构. 可以理解为“排好序的快速查找数据结构” 在数据之外,数据库系统还维护着满足特定查找算法的 ...

  6. FP真验货客户的成品和半成品编码部分没有带尾续,导致FP规划错误 IN_SALES_ORDER数据不带CZ

    错误描述:真验货客户的成品和半成品编码部分没有带尾续,导致FP规划错误 IT角度: IN_SALES_ORDER数据不带CZ 现时前台页面数据: 现时后台数据: 一.跟进情况 1.执行SAP_SALE ...

  7. ASP.NET中UrlEncode应该用Uri.EscapeDataString()(转)

    今天,茄子_2008反馈他博客中的“C++”标签失效.检查了一下代码,生成链接时用的是HttpUtility.UrlEncode(url),从链接地址获取标签时用的是HttpUtility.UrlDe ...

  8. 配置Tomcat 7 Gzip

    <Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" ...

  9. Element div is not closed

    报错内容:Element div is not closed 解决方法: 将代码复制到NotePad++.SubLime Text等文本编辑器中,另存为.jsp或者.html文件. 这样可以利用语法高 ...

  10. hdoj2612 Find a way (bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 思路: 这个题我wa了十多发QAQ. 刚开始的思路是搜索每个‘@’,然后广搜该点到Y和M的最小距 ...