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. POI 生成带联动下拉框的excel表格

    参考:https://www.cnblogs.com/cjbbk/p/7527276.html 解决POI3.17 与其它版本的不同的坑:https://blog.csdn.net/Weirdo_zh ...

  2. 机器学习入门-提取文章的主题词 1.jieba.analyse.extract_tags(提取主题词)

    1.jieba.analyse.extract_tags(text)  text必须是一连串的字符串才可以 第一步:进行语料库的读取 第二步:进行分词操作 第三步:载入停用词,同时对分词后的语料库进行 ...

  3. 返回顶部 fixed oncheck(点击按钮)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. hibernate-list

    Hibernate多表关联查询类: 1. sql查询两个或两个以上的字段,默认情况下,list中封装的是Object[],长度与所查询的字段数一致.这种方式获取的数据只能通过index下标获取. su ...

  5. 运行tomcat显示指定的服务未安装解决办法

    一.问题重现 二.原因分析 tomcat7.exe和tomcat7w.exe要起作用必须先未这两个文件安装服务. 其中tomcat7.exe这个文件是用来启动tomcat的,tomcat7w.exe这 ...

  6. bmp和Variant的转换

    procedure TForm2.VariantToBMP(aValue : OleVariant;var aBmp:TBitmap); var    Stream : TMemoryStream;  ...

  7. Interrupt handler

    1.处理器上的中断硬件关系图 2. 中断处理例程 3. 顶半部与底半部

  8. Ansible test

    [root@localmesos ansible_test]# ansible all -a "/bin/echo hello"192.168.111.111 | SUCCESS ...

  9. dom node 查找父级parentNode

    var o = document.querySelectorAll("a[href='baidu.com']"); var p = o[o.length-1];console.lo ...

  10. Structs配置文件 zg项目介绍

    Structs配置文件 1.以系统代码为名称 例: