Java.lang.ClassNotFoundException when running java -jar (still unsolved)?

The error seems actually related to your MANIFEST which.

Could not find the main class: MyClass The error seems actually related to your MANIFEST which: may not have a complete classpath Class-Path: see this HowTo The best solution when you have a jar is to try to include the required jars into the manifest declaration. Manifest-Version: 1.0 Class-Path: customer_client. Jar mailer_client.

Jar signon_client. Jar or may not define adequately the MainClass within your 'my_jar. Jar'.

See this HowTo: the needs to specify the full path (packages) of the MainClass, not just MainClass. If your main class is in the default package (the unnamed package), I am not sure it can be referenced by the loader (see this SO question) So move your JarRunner into a package, and declare it appropriately in the element.

The main class is declared as class JarRunner and is in JarRunner. Java in the same directory as build.xml. In my manifest, the attribute looks like: attribute name="Main-Class" value="JarRunner"/> Is this wrong?

– Heinrich Schmetterling Nov 25 '09 at 8:35 I would recommend at least one package to put JarRunner into, instead of the "unnamed package" – VonC Nov 25 '09 at 8:43 If I add my java files to a package and then specify the MainClass as mypackage. JarRunner it still can't find the class. Is this the right thing?

– Heinrich Schmetterling Nov 25 '09 at 8:47 Does this explanation make sense when considering that if I take away the missing org. Apache code but leave the imports, it runs ok? – Heinrich Schmetterling Nov 25 '09 at 8:48 Yes it does, since the Could not find the main class: MyClass is actually triggered by the fact one of its part (the apache class) is not found.So my previous comment do not help here.

– VonC Nov 25 '09 at 8:51.

You need to specify all the other jars that are required in your classpath in the manifest file before you can execute java -jar my-test. Jar, here is a copy of one of my manifest files. With all these entries in the manifest I can specify java -jar db_field_cleaner.

Jar and all the other jars are inlined into the classpath : Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: James B Build-Jdk: 1.6.0_01 Package: com.blah. Dbfieldcleaner Specification-Title: db_field_cleaner Specification-Version: 2.5.7-SNAPSHOT Implementation-Title: db_field_cleaner Implementation-Version: 2.5.7-SNAPSHOT Implementation-Vendor-Id: com.blah. Dbfieldcleaner Implementation-Vendor: Main-Class: com.blah.dbfieldcleaner.main.

Main mode: development url: ..\..\db_field_cleaner\target\site Class-Path: log4j-1.2.14. Jar cygna_commons-2.5.7-SNAPSHOT. Jar mail-1.4 .

Jar activation-1.1. Jar jdic-0. 9.5. Jar jdic_native-0. 9.5.Jar jdic_plu s-0.

2.2. Jar jdic_plus_native-0. 2.2. Jar jtds-1. 2.2.Jar xstream-1.3.1.

J ar xpp3_min-2.2.c. Jar commons-net-2.0. Jar text_processing-2.5.7-SNAP SHOT.

Jar Alternatively, use Maven, it's loads better at this kind of stuff!

You had given answer yourself :-) add all the jars to your runtime classpath. As you said earlier *. Jar solved one problem but loggers are not able to find out, so add log4j.

Jar to the path. Basically the idea is add all the jars required for running in to classpath.

The command line options for java can be found here. The -jar and -cp/-classpath options are mutually exclusive. The -jar option requires the use of a manifest and the relative paths to dependencies should be listed in this file.

But essentially, the manifest is an optional mechanism - you can specify the required information externally at bootstrap time. If the manifest is causing you problems, don't use one. I would test that you have you have located all your dependencies with a command like this: java -cp /usr/local/lib/libthrift.

Jar:my_jar. Jar MyClass Note that the compiler may successfully compile your classes even if all the classes that might be required at runtime are not present. Compilation will succeed if the direct dependencies of your classes are present.

The dependencies of your dependencies are not necessary to create the binary and the compiler will not inspect them needlessly. The message about org/apache/log4j/Logger suggests that you have a missing dependency on log4j. It will be necessary to add this library to the classpath.

Check the documentation for the Thrift library to determine its dependencies.

The class path references in the manifest file are relative refs. Just to debug, you might want to copy all the jars into the same location as my_jar. Jar and attempt it again.

Reference : rgagnon.com/javadetails/java-0587.html.

You might try adding the jars to the domain of the server. I had a similar problem and this worked for me when I was running it on glassfish. I would get those not found exceptions.

Eclipse recognized it and it compiled fine but when ran on the server it couldn't find the file. Try adding it to whatever lib directory the server is installed to.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions