Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why won't the program run?

 
Matt Kidd
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matt Kidd
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're assuming in the above that d:\program is your current working directory , but perhaps that's not the case?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic