Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DaysOld and classpath

 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I can compile fine using the provided zip file and javac and classpath settings. I can't seem to convince java.exe to behave similarly.
Any advice?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error I get is the old NoClassDefFoundError
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also known as GoJumpInALakeError
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I know what I did wrong.
The classpath setting for javac doesn't need to include the location of the class that I'm about to create. So, not specifying the current working directory (the one where the class file I'm creating will be) is no problem. java does need to know the location of all class files I want to use - including the location of the class I am executing (which for some asinine reason it can't find all by itself if it's in the current working directory). The solution then becomes:
java -classpath ".;.\whatever" SomeClass [someArguement(s)]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll leave this monologue for future perusers (me in a month).
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
The error I get is the old NoClassDefFoundError

Yeah, it's the one I call java.lang.Nope
 
Michael Matola
whippersnapper
Ranch Hand
Posts: 1817
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, one of the best tricks I learned is
java -classpath . SomeClass
My machine at work is locked down and I can't change the path or classpath, so I wind up having all sorts of path and classpath adventures when I get the urge to do some Java on the sly. (My work doesn't involve Java programming, as you could probably guess.)
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Matola:
Yep, one of the best tricks I learned is
java -classpath . SomeClass
My machine at work is locked down and I can't change the path or classpath, so I wind up having all sorts of path and classpath adventures when I get the urge to do some Java on the sly. (My work doesn't involve Java programming, as you could probably guess.)

Thomas Paul introduced me to an even better trick . . . Ant.
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone not knowing about what Ant means:
A sort of makefile using XML (extended markup language) and Java.
Ant is available from jakarta.apache.org
Worthwhile!
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas Paul also wrote about ant in the JavaRanch Newsletter in March.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic