?
Solved

JAVA Problem with classpath

Posted on 2003-02-25
14
Medium Priority
?
675 Views
Last Modified: 2013-11-23
Hi All,

I am almost new to Java and trying to learn some stuff. would appreciate help pls..

I am trying to learn about FREETTS (JAVA SPEECH SOFTWARE from SUN). I downloaded it and unzipped it..

It created some folders like

c:\javaspeech\FreeTTS\demo\JSAPI\HelloWorld

In this HelloWorld folder are these files..

HelloWorld.java
helloworld.au
and also run.bat

run.bat looks like this..

javac -classpath ..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\cmukal8.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.jar -d ..\..\..\classes *.java
java -cp ...\..\classes;..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\cmukal8.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.jar %1


so I did from DOS as run HelloWorld

It created HelloWorld.class in the following directory..

c:\JavaSpeech\FreeTTS\classes as from first statement in run.bat

now from 2nd statement, it should run HelloWorld..

it showed me this error..


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


Below is the whole thing I did in DOS..


C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>run HelloWorld

C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>javac -
classpath ..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\cmukal8
.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.jar -d
..\..\..\classes *.java

C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>java -c
p ...\..\classes;..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\
cmukal8.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.
jar HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>


Help me with this plz
0
Comment
Question by:irodov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +3
14 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 8020211
Try java -cp .; <then the rest of the classpath>
0
 

Author Comment

by:irodov
ID: 8020788
I tried this..


C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>java -c
p.; ..\..\classes;..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib
\cmukal8.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi
.jar HelloWorld
Unrecognized option: -cp.;
Could not create the Java virtual machine.



help plz
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8020911
There should be a space between the 'p' of cp and the dot for the current directory
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:vano42
ID: 8022251
the above solution is correct, however you need a space between -cp and ".;...".  Because you left out a space jvm did not recognize the -cp option
0
 
LVL 2

Assisted Solution

by:warsql
warsql earned 200 total points
ID: 8022622
In
C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>javac -
classpath ..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\cmukal8
.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.jar -d
..\..\..\classes *.java
the important part to note is -d ..\..\..\classes which means that compiled classes will be put in ..\..\..\classes.  Therefore, your classpath needs to include ..\..\..\classes, but in

C:\JavaSpeech\FreeTTS\demo\JSAPI\HelloWorld>java -c
p ...\..\classes;..\..\..\lib\cmuawb.jar;..\..\..\lib\cmukal16.jar;..\..\..\lib\
cmukal8.jar;..\..\..\lib\cmulex.jar;..\..\..\lib\freetts.jar;..\..\..\lib\jsapi.
jar HelloWorld

you have ...\..\classes.  Change this to ..\..\..\classes
0
 

Author Comment

by:irodov
ID: 8025602
warsql's solution is working for me, I really appreciate the help..

before i close this question, could you pls tell me what does classpath means? I mean, when we do java helloworld..

is it that it looks for all classes needed for helloworld to run looking in classpath.. and as it keeps on finding it, it keeps saying ok ok..

when i set my environment variable CLASSPATH=...

Now when i do java helloworld.. does JVM looks at this env. variable to find out all related classes..

does JVM looks at java -cp classpath first or environment variable classpath first .. it looks at both though right??

if i put  ..\..\classes in my classpath env. variable, will it include all classes in this directory..

so does it means that if i put ..\..\classes\helloworld in my classpath env. variable..

to run this class, i can run it from any directory.. like for example if i do..

c:\java helloworld it shud run because JVM will look in classpath env. variable, find this class and it will run..

am i understanding the classpath correctly..

this wud be my last bunch of questions.. sorry to bother you..

regards
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8025834
Actually i noticed the three dots/two dots thing too - but made an incorrect assumption: namely that anyone that can cope with such a mess of relative paths knows exactly what the difference is between the is and is aware of what is being used!

I'll let warsql answer your remaining questions, since he'll be taking the points, but will say that you should let Java's extensions mechanism work for you. If you put all those jar files in the \lib\ext directory of your active runtime, then theoretically you don't need a classpath at all. I myself hardly ever have one set.
0
 

Author Comment

by:irodov
ID: 8026356
CEHJ,

Thanks for your reply, actually I don't know much of relative paths and the whole mess above. I am just learning the stuff. It was a mistake in run.bat file which comes with FREETTS package from SUN for JavaSpeech.

I just ran as they told and got into this mess.

WARSQL, whenever you getta chance, cud u pls reply my rest q's and i will close the question. I just want to learn Java stuff and trying some experiments.. and so coming up with these questions..

CEHJ, I have tons of q's coming soon because I am playing lot in Java these days and ofcourse facing heck lot of problems.. hope u can help me with some..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8026395
Sure ;-)
0
 
LVL 2

Expert Comment

by:warsql
ID: 8029566
The classpath is a list of directories and jar (or zip) files that is used by the java virtual machine (jvm or just vm) to find any and all classes needed to run your application.  The vm will use your system environment variable CLASSPATH as its classpath by default when an application is run.  You can override this behavior by specifying the -cp "(classpath)" option at runtime.  This hides the system environment variable CLASSPATH and uses the specified classpath instead.  You can specify %CLASSPATH% within your specified classpath to also include the system classpath.

There also is a special directory in your filesystem that will automatically be included in addition to whatever classpath is specified.  That directory, as CEHJ said, is the lib\ext directory in the vm directory that you are using.  This will be something like c:\j2sdk1.4.1\jre\lib\ext on your windows machine.  Whatever classes or jars you put in that directory don't need to be on your specified classpath.

Hope that clears that up for you.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8032769
If you pass the parameter "java.ext.dirs" to this programme you can discover what your active extension directory is (often not what one expects):

public class Props {

  public static void main(String[] args){
    if(args.length > 0){
     for(int i = 0;i < args.length;i++){
      System.out.println(System.getProperty(args[0]));
     }
    }
    else {
      System.getProperties().list(System.out);
    }
  }
}
0
 

Expert Comment

by:CleanupPing
ID: 9059081
irodov:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9671887
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between warsql and CEHJ

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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