• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javac and jar for entire project: NoClassDefFoundError (resolved)  RSS feed

 
Eddy Paredes
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a project that I've developed in Netbeans. It works wonderful in Netbeans. I can run and build a jar out of it without problems but when I try to do this manually with javac and jar I get this:

Exception in thread "main" java.lang.NoClassDefFoundError: classes/projectname/packageX/Classname (wrong name: projectname/packageX/Classname)y

What have I done wrong?

This is what I've tried (src is where the java files are in):

javac -d classes -deprecation -sourcepath src src/projectname/packageX/Classname.java

then

jar cfe runme.jar projectname.packagex.Classname classes

I do not use any external library or jar file for that project. Any idea?
[ March 21, 2008: Message edited by: Eddy Paredes ]
 
Eddy Paredes
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a solution here.

In my case it was:

# Compiling sourcecode files.
javac -d classes -deprecation src/procjectname/*/*.java

# Making the JAR file.
echo Creating the executable JAR archive...
jar cfe runme.jar projectname/packageX/Classname -C classes .

The point is important!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!