Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem in setting CLASSPATH

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have set an environmental variable CLASSPATH which has the value .;C:\Java\jdk5.0\lib\dt.jar;C:\Java\jdk5.0\lib\tools.jar;C:\Java\jdk5.0\lib\servlet-api.jar;C:\Java\jdk5.0\lib\jsp-api.jar

Now I am trying to compile a servlet like:

> javac -classpath E:\ABC\classes XYZServlet.java

In this case I am getting error that package javax.servlet.* not found

And if I do not spcify the -classpath option then I got error:
package com.exampe.model not found

where my servlet has the foolowing line:
import com.example.model.*;

Thus, only one classpath is read.
How to use both the packages?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry, the command line does not override your CLASSPATH setting. What is under E:\ABC\classes ? Your java files ? With your command line, I expect to see something like E:\ABC\classes\com\example\model. Are your source files there ?

Another thing, is this a typo ? "package com.exampe.model not found". The "l" in example is missing.
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was a typing mistake only(in this post)...

If command line does not override the CLASSPATH setting, then why it is the case that I am getting "package javax.servlet not found" when I am specifying -classpath option in the command line and I am getting "package com.example.model not found" instead of "package javax.servlet not found" when I am not specifying the -classpath option.

I have put my .java(helper classes, not servlets) files in E:\ABC\src\com\example\model and my .class files for these .java files are in E:\ABC\classes\com\example\model
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, apologizes. It will override your environment variable. You'll have to use one or the other. Look at this FAQ, and set the current directory "." in the CLASSPATH too. Then compile from the root of your source directory.
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, Christophe
 
I just had the craziest dream. This tiny ad was in it.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic