0



I have this code in Java that I'm to compile and execute. The code itself is working and the compilation goes ok. When I execute the code giving the classpath, with a command like "java -cp classes:lib/* main.class parameters" it works well.
But the problem is when I try to generate a jarfile and execute it with a command like "java -jar file.jar parameters". When I execute this, code starts running but crashes on the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy<br>
at java.lang.ClassLoader.defineClass1(Native Method)<br>
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)<br>
at [...]
Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.TrustStrategy<br>
at [...]
... 17 more


I thought it could be missing some class on MANIFEST, though for what I could find on the internet, the package providing this class is httpcore, which is included there. I tried to modify in many ways the manifest with no success, so I don't believe the problem is on this file.
I don't know if it helps, but the code is being compiled with ant and I have some 3rd-party libs stored on a lib folder, which is on the classpath of MANIFEST.
I'm compiling on a computer with:

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

And running it on a computer with:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)



Does anyone know why may this be happening?

Aldeguer
  • 821
  • 9
  • 32
  • 1
    The httpcore class must be actually included in `file.jar`, not just the manifest file. How are you generating `file.jar`? – jingx Nov 07 '17 at 15:00
  • I'm generating it with "ant jar" command. The code has some configuration files for ant and these files are including all .jar inside the lib folder and doing a bunch of other stuff. I'm aware that the class must be included. In the manifest file inside the .jar, is specified the classpath to the lib folder, which is on the same path of the .jar. This part is correct, isn't it? – Lucas Vilela Nov 07 '17 at 23:33

0 Answers0