java - How to set Class-Path indict jar in the same jar -
i want create finish single jar ball include of dependencies, can shipped 1 utilize command line .
the construction of jar :
├── meta-inf │ ├── manifest.mf │ └── maven │ └── com.cn.xing.jar │ └── cnjar │ ├── pom.properties │ └── pom.xml ├── com │ └── cn │ └── xing │ └── jar │ ├── hellojava.class │ └── injectentry.class ├── lib │ ├── aopalliance-1.0.jar │ ├── commons-codec-1.6.jar │ ├── commons-logging-1.1.3.jar │ ├── gson-2.2.4.jar │ ├── httpclient-4.3.5.jar │ ├── httpcore-4.3.2.jar │ ├── spring-aop-3.2.2.release.jar │ ├── spring-beans-3.2.2.release.jar │ ├── spring-context-3.2.2.release.jar │ ├── spring-core-3.2.2.release.jar │ └── spring-expression-3.2.2.release.jar └── spring └── appctx.xml
and manifest file content :
manifest-version: 1.0 built-by: chinaxing build-jdk: 1.7.0_65 class-path: lib/spring-context-3.2.2.release.jar lib/spring-aop-3.2.2. release.jar lib/aopalliance-1.0.jar lib/spring-beans-3.2.2.release.ja r lib/spring-core-3.2.2.release.jar lib/spring-expression-3.2.2.relea se.jar lib/httpclient-4.3.5.jar lib/httpcore-4.3.2.jar lib/commons-lo gging-1.1.3.jar lib/commons-codec-1.6.jar lib/gson-2.2.4.jar created-by: apache maven 3.2.2 main-class: com.cn.xing.jar.injectentry archiver-version: plexus archiver
but when execute in command line next :
java -jar ../cnjar-1.0-snapshot.jar
it show exceptions :
exception in thread "main" java.lang.noclassdeffounderror: org/springframework/context/applicationcontext @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(class.java:2688) @ java.lang.class.getmethod0(class.java:2937) @ java.lang.class.getmethod(class.java:1771) @ sun.launcher.launcherhelper.validatemainclass(launcherhelper.java:544) @ sun.launcher.launcherhelper.checkandloadmain(launcherhelper.java:526) caused by: java.lang.classnotfoundexception: org.springframework.context.applicationcontext @ java.net.urlclassloader$1.run(urlclassloader.java:372) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:360) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) ... 6 more
which means spring jar cannot found .
so want know how allow jvm classloader found jar(s) in jar's lib
dir ?
default class loader not handle case. can :
write classloader handle case re-package jars (see maven-shade-plugin, maven jarja plugin) see http://one-jar.sourceforge.net java classloader
No comments:
Post a Comment