`

jar文件Could not find the main class解决办法

    博客分类:
  • JAVA
阅读更多
辛辛苦苦写了个java的DES字符加解密程序,准备送给朋友的,做完导出成JAR文件,却发现不能运行。Could not find the main class:Mycipher.jar Program will exit.郁闷大了,之前做个很多的jar文件都能运行的,这次确不行,上网搜了搜,问的一大堆,却没真正解决问题的原因,决定自己动手了。
程序再Eclipse中能运行,程序肯定没有问题,用Eclipse的向导导出应该也不会有问题,唉,直接执行不了,到cmd试一下,java -jar MyCipher.jar,报错了,一看错误,是某个类找不到,这个类是我应用的jar文件里的,这让我想到了jvm的类装载机制,一定是类装载器在当前路径里找不到我引入的jar文件里的类。终于让我发现的问题的真正原因。

解决办法:
1.把lib目录里的jar文件一一解压,把解压后的类文件连同目录添加到Mycipher.JAR文件中,很easy的搞定。
2.修改MANIFEST.MF文件的Class-Path属性的值(目录路径用/或者.代替,jar之间用空格分开)如:Class-Path: ../lib/miglayout-3.5.5.jar  ../lib/TableLayout.jar  ../lib/swing-layout-1.0.jar,同时把用到的jar文件放到指定的路径下。

JAR文件的详解
http://www.ibm.com/developerworks/cn/java/j-jar/
4
0
分享到:
评论
2 楼 xsmmk 2011-10-13  
我下载了怎么运行部了哦
1 楼 150312q 2011-08-23  

相关推荐

    WIN7下运行Jar文件提示Could not find the main class

    WIN7下运行Jar文件提示Could not find the main class

    win7 解决导出jar包提示 can not find the main class

    win7 下 myeclipse 导出jar包后 不能双击运行,只能从dos中打开 修改文件关联执行命令

    jd-gui-1.4.0

    java反编译工具jd-gui, 1.4.0版本, 使用方式: 打开的文件应该为类似jar包文件,而不是单独的Class文件

    java反编译工具jd-gui-1.4.0.jar

    java反编译工具jd-gui-1.4.0.jar 可以查看jar包中的.class文件的java代码

    java打jar包的方法

    解决Could not find the main class, Program will exit的错误的方法

    人大金仓驱动包kingbasejdbc.jar V8.6.0、8.8.0驱动jar包

    ${basedir}/src/main/resources/jar/kingbase8-8.6.0.jar jdbc driver-class-name: com.kingbase8.Driver url: jdbc:kingbase8://127.0.0.1:54321/template1?characterEncoding=utf8 username: system password: ...

    打jar包注意点.docx

    <mainClass>com.csii.pe.channel.stream.context.IoCContainerStart</mainClass> <!-- 是否指定项目classpath下的依赖 --> <addClasspath>true <!-- 指定依赖的时候声明前缀 --> <classpathPrefix>./lib/ ...

    eclipse 下打包

    的错误 <br>如果没有使用其他插件啊,类库等,以上的步骤就可以了 但如果用了,例如我用了SWT,就麻烦一点了 如果不作以下操作,会出现 Could not find the main class, Program will exit. 的错误。...

    sqoop-1.4.7.jar

    解决错误:Could not find or load main class org.apache.sqoop.Sqoop。把这个sqoop-1.4.7.jar放到sqoop根目录下的lib目录中,即可。 如果你没有积分,也可以自己去这个地址下载:...

    Java邮件开发Fundamentals of the JavaMail API

    The API's main purpose is not for transporting, delivering, and forwarding messages; this is the purview of applications such as sendmail and other Mail Transfer Agent (MTA) type programs. MUA-type...

    sqoop1.46和1.47

    sqoop框架开发工具使用的jar,目前版本有1.4.6和1.4.7两个jar包,启动Sqoop时,抛出异常:Error: Could not find or load main class .usr.local.sqoop-1.4.7.sqoop-1.4.7.jar 则可以下载资源将sqoop-1.4.7.jar放到...

    抛出无法找到主类:org.apache.axis.wsdl.WSDL2Java

    抛出无法找到主类:org.apache.axis.wsdl.WSDL2Java(Throws Could not find main class: org.apache.axis.wsdl.WSDL2Java)。 添加本文的jar包压缩包解压出来的所有jar包到当前使用的java.exe 命令的lib目录下的ext...

    myEclipse工程打包及exe文件制作

    包括meEclipse下如何制作jar文件 制作exe文件 JavaLanuncher reshacker,manifes.txt项目清单文件的写法

Global site tag (gtag.js) - Google Analytics