Solved

ClassNotFoundException in production, Even if my jar file is set in classpath

Posted on 2009-05-12
9
665 Views
Last Modified: 2012-05-06
Hi,

I have created jar file from Netbeans and deployed my jar file in production server

I am setting classpath to my jar file

Still I am getting ClassNotFoundException

Can you please help me

Thanks



D:\SMEC\Core>set classpath = %classpath%;D:\SMEC\Core\NewsletterMailMerge.jar;
 

D:\SMEC\Core>java newslettermailmerge.NewsletterMain

Exception in thread "main" java.lang.NoClassDefFoundError: newslettermailmer

ge/NewsletterMain

Caused by: java.lang.ClassNotFoundException: newslettermailmerge.NewsletterM

ain

        at java.net.URLClassLoader$1.run(Unknown Source)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

        at java.lang.ClassLoader.loadClass(Unknown Source)

        at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Could not find the main class: newslettermailmerge.NewsletterMain.  Program

will exit.
 
 
 

D:\SMEC\Core>dir

 Volume in drive D is App

 Volume Serial Number is 50DD-4825
 

 Directory of D:\SMEC\Core
 

12/05/2009  14:37    <DIR>          .

12/05/2009  14:37    <DIR>          ..

12/05/2009  13:07               448 AppConfig.properties

10/05/2009  12:36             3,694 log4j.xml

12/05/2009  13:08           251,512 NewsletterMailMerge.jar

11/05/2009  18:19            46,445 NewsletterMailMerge.xml

12/05/2009  13:08             1,462 README.TXT

               7 File(s)        361,417 bytes

               4 Dir(s)  10,831,269,888 bytes free
 

D:\SMEC\Core>
 
 
 

D:\SMEC\Core\NewsletterMailMerge>dir

 Volume in drive D is App

 Volume Serial Number is 50DD-4825
 

 Directory of D:\SMEC\Core\NewsletterMailMerge // Extracted jar file using Win rar 
 

12/05/2009  14:37    <DIR>          .

12/05/2009  14:37    <DIR>          ..

12/05/2009  13:08               448 AppConfig.properties

12/05/2009  13:08    <DIR>          com

12/05/2009  13:08            14,848 employees.xls

12/05/2009  13:08            43,008 HTMLEncoding.xls

12/05/2009  13:08    <DIR>          META-INF

12/05/2009  13:08    <DIR>          newslettermailmerge

12/05/2009  13:08    <DIR>          Templates

               3 File(s)         58,304 bytes

               6 Dir(s)  10,831,269,888 bytes free
 

D:\SMEC\Core\NewsletterMailMerge>
 
 
 

D:\SMEC\Core\NewsletterMailMerge\newslettermailmerge>dir

 Volume in drive D is App

 Volume Serial Number is 50DD-4825
 

 Directory of D:\SMEC\Core\NewsletterMailMerge\newslettermailmerge
 

12/05/2009  13:08    <DIR>          .

12/05/2009  13:08    <DIR>          ..

12/05/2009  13:08             3,409 NewsletterMain$1.class

12/05/2009  13:08             8,865 NewsletterMain.class

               2 File(s)         12,274 bytes

               2 Dir(s)  10,831,269,888 bytes free
 

D:\SMEC\Core\NewsletterMailMerge\newslettermailmerge>

Open in new window

0
Comment
Question by:tia_kamakshi
  • 5
  • 3
9 Comments
 
LVL 12

Expert Comment

by:Gibu George
ID: 24364653
Post the contents of the manifest file
0
 

Author Comment

by:tia_kamakshi
ID: 24364681
Here it is

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 11.0-b16 (Sun Microsystems Inc.)
Main-Class: pbmsnewslettermailmerge.NewsletterMain
Class-Path: lib/log4j-1.2.15.jar lib/antlr-2.7.6.jar lib/asm.jar lib/a
 sm-attrs.jar lib/cglib-2.1.3.jar lib/commons-collections-2.1.1.jar li
 b/commons-logging-1.1.jar lib/dom4j-1.6.1.jar lib/ehcache-1.2.3.jar l
 ib/jdbc2_0-stdext.jar lib/jta.jar lib/hibernate3.jar lib/hibernate-to
 ols.jar lib/hibernate-annotations.jar lib/hibernate-commons-annotatio
 ns.jar lib/hibernate-entitymanager.jar lib/javassist.jar lib/ejb3-per
 sistence.jar lib/sqljdbc.jar lib/jxl.jar lib/activation.jar lib/mail.
 jar lib/jxls-core-0.9.6.jar lib/jxls-reader-0.9.6.jar lib/commons-jex
 l-1.0.jar lib/poi-3.2-FINAL-20081019.jar lib/poi-contrib-3.2-FINAL-20
 081019.jar lib/poi-scratchpad-3.2-FINAL-20081019.jar lib/commons-logg
 ing-1.1.jar lib/junit-3.8.1.jar
X-COMMENT: Main-Class will be added automatically by build

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24364699
All you should need is


java -jar yourjar.jar
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24364704
Of course all the other jars should be copied too (mainly in the lib dir below your main jar)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:tia_kamakshi
ID: 24364771
Many Thanks

I am running through .bat file

I gets error message saying that

C:\>outlook.bat
ECHO is off.
ECHO is off.
Unable to access jarfile NewsletterMailMerge.jar
C:\>d:


Here is my contents of .bat file

@echo off
echo %1
echo %2

set classpath = %classpath%;D:\SMEC\Core\NewsletterMailMerge.jar;

cd D:\SMEC\Core\

java -jar NewsletterMailMerge.jar para1 param2


0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24364797
Forget classpath - it will be ignored
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24364829
All you need is something like
@echo off
 

d:

cd D:\SMEC\Core\

java -jar NewsletterMailMerge.jar %*

Open in new window

0
 

Author Closing Comment

by:tia_kamakshi
ID: 31580527
Many Many Thanks...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24365458
:-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 56
VB Script to add site to Java Exception List 4 53
object oriented programming comparison 5 55
java stored proc example 9 22
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now