• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Including multiple JARs in javac -classpath

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to use the Str class from the jr.jar library when working with a servlet - but the second jar file listed in the command below doesn't seem to get picked up.

$ javac -cp ~/tomcat/apache-tomcat-6.0.20/lib/servlet-api.jar:~/tomcat/apache-tomcat-6.0.20/lib/jr.jar -d classes src/filename.java

Any thoughts? Thanks much.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you re-check if the jar is in the folder that you specified. Also can you show us the code in which you are trying to access a class from that jar. Maybe you've made a mistake in capitalization or something else...
 
Riley Thomas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jr.jar file is definitely located in the /lib directory.

Here is what I'm trying to compile:



The error is: src/NowServlet.java:4: package com.javaranch.common does not exist
import com.javaranch.common.*;
^
1 error
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Riley Thomas wrote:The jr.jar file is definitely located in the /lib directory.


I guess you mean the ~/tomcat/apache-tomcat-6.0.20/lib directory, as that's what you're putting in the classpath?

It looks like you're using a Unix-like operating system (maybe Linux or Mac OS X). Check if the jr.jar file contains what you expect. Try this command to list what's inside the jar:

jar tvf ~/tomcat/apache-tomcat-6.0.20/lib/jr.jar

It should show you a list of the files and directories in the jar file. Does it contain a directory com/javaranch/common?
 
Riley Thomas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I double-checked the file and it does contain the com/javaranch/common directory.

Correct, I am using OS X with Java 1.5.

I've found that if I reverse the order of the jar files - typing:
$ javac -cp ~/tomcat/apache-tomcat-6.0.20/lib/jr.jar:~/tomcat/apache-tomcat-6.0.20/lib/servlet-api.jar -d classes src/***.java - it returns errors regarding the javax.servlet classes; so whatever comes second in that classpath list doesn't work.
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please try this:


it worked for me
 
Riley Thomas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and it worked for me too - thanks!

Time to start using ANT now
 
reply
    Bookmark Topic Watch Topic
  • New Topic