• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SOS

 
V Bose
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My directory structure is

The file Normalize.java has a package statement
package src;
From the directory Cluster (@ the DOS prompt) when I try
java -cp build\src Normalize
it throws

Exception in thread "main" java.lang.NoClassDefFoundError: Normalize (wrong name: src/Normalize)

How do I get this class to run ?
Thanks
[ February 18, 2004: Message edited by: V Bose ]
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is you're going in to the package. Do this instead:
java -cp build src.Normalize
 
Sarah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you wrote "package src;" at the top of your class, you will have to run the class by referring to it as "src.Normalize".
So to run the class from the Cluster directory, try:
java -cp build src.Normalize
So you're pointing java to the directory above the beginning of your package hierarchy (you only have one level in your package "src") and then refer to the class using the package name "dot" class name. So if you had more levels in your package like "package com.pizzahut.util;" then you will refer to your class as "com.pizzahut.util.Normalize" in order to run it.
 
David Peterson
author
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case the class name is src.Normalize and the class files are stored under the "build" folder, so java -cp build src.Normalize should get it running.
However, calling your package "src" is not perhaps the most descriptive name you could come up with. In fact it is misleading and could cause confusion with the real source directory "Cluster/src".
The convention is to use your domain name (in reverse order) followed by a descriptive name for the package. For example, if you owned the domain name "vbose.com" you might like to place your class in the package "com.vbose.cluster".
Talking of names, the name of the class "Normalize" appears to describe an action (method) rather than an object / class?
Regards,
David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic