This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why won't the program run? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why won Watch "Why won New topic
Author

Why won't the program run?

Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 259
I know it's something simple and I'll kick myself but...

I have a folder located here: D:\program\

Within that folder are 4 txt files: combined, domain, test, url

1 java file: proxy.java

1 class file: proxy.class


For whatever reason the program won't run and the error is: Exception in thread "main" java.lang.NoClassDefFoundError: proxy

Yet as you can see the proxy.class file is there. I've tried java D:\program\proxy as well as adding the extention too. Oh and I've tried running the program from the folder as well. I have not tried running it from where java is located on my machine. If it will help I've pasted the code below:

Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Dear Reader,
Well, I guess you should check your CLASSPATH environment variable. It MUST include atleast this


.;


Apart from that it may include other information.

Yet, I suggest that you try this first:



Give that command from within the program folder.

[ May 09, 2006: Message edited by: Shyam Prasad Murarka ]
[ May 09, 2006: Message edited by: Shyam Prasad Murarka ]

With Best Regards,
Shyam Prasad Murarka
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You've set the environment variable CLASSPATH, but you haven't set it to include "." (dot), representing the current directory.

Either add "." to your CLASSPATH, or (my personal recommendation) unset this environment variable altogether. The best setting for people new to Java is no setting at all -- the default would have worked fine for you here.

Note that CLASSPATH and PATH are distinct and unrelated. PATH is used by the OS to find programs to run (like java.exe). CLASSPATH is used by Java to find *.class files to run. The OS knows nothing about CLASSPATH, and Java knows nothing about PATH.


[Jess in Action][AskingGoodQuestions]
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 259
Originally posted by Shyam Prasad Murarka:
Dear Reader,
Well, I guess you should check your CLASSPATH environment variable. It MUST include atleast this



Give that command from within the program folder.

[ May 09, 2006: Message edited by: Shyam Prasad Murarka ]

[ May 09, 2006: Message edited by: Shyam Prasad Murarka ]


neither worked.
Matt Kidd
Ranch Hand

Joined: Jul 17, 2002
Posts: 259
Originally posted by Ernest Friedman-Hill:
You've set the environment variable CLASSPATH, but you haven't set it to include "." (dot), representing the current directory.

Either add "." to your CLASSPATH, or (my personal recommendation) unset this environment variable altogether. The best setting for people new to Java is no setting at all -- the default would have worked fine for you here.

Note that CLASSPATH and PATH are distinct and unrelated. PATH is used by the OS to find programs to run (like java.exe). CLASSPATH is used by Java to find *.class files to run. The OS knows nothing about CLASSPATH, and Java knows nothing about PATH.



check that...it did...neglected to restart the command window. thank you.
[ May 09, 2006: Message edited by: Matt Kidd ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

We're assuming in the above that d:\program is your current working directory , but perhaps that's not the case?
 
jQuery in Action, 2nd edition
 
subject: Why won't the program run?
 
Similar Threads
buffer?
Trouble writing to a text file
Tokenized Data
Writing data into file from a String variable
Flagging duplicate lines when comparing the input from two seperate text files