Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LinkHashMap problem!

 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!

This compiles fine, but when i go to run it, it gets the following error:

C:\antlr.xref\src\org\antlr\java\crossref>java x . > o
Exception in thread "main" java.lang.NoClassDefFoundError: java/util/LinkedHashM
ap

And if i change the LinkedHashMap to a HashMap, it runs ok!

Any insights would be appreciated!

bc

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 23, 2004: Message edited by: Dirk Schreckmann ]
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you run your program, does your classpath include tools.jar file ? The one that comes with JDK/JRE ? Make sure it does.
 
bob connolly
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dmitry!

You are correct, it was a classpath problem!

Have a nice weekend, appreciate the help!

bc
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may well have had a CLASSPATH problem, but I wouldn't suspect that adding tools.jar to be the likely solution. tools.jar doesn't contain the J2SE API. It contains some tools, for doing things like compiling at runtime.

rt.jar contains the J2SE API, but it shouldn't need to be added to the CLASSPATH, as the JRE should be able to locate it automatically.

For your CLASSPATH setting, if you don't need anything not in the J2SE API, then I'd suggest either not specifying a CLASSPATH value, or simply specifying that the current working directory, represented by a period, is in your CLASSPATH.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic