Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Compiling a java servlet at dos prompt that uses a precompiled class

Posted on 2004-04-06
Last Modified: 2013-11-24
Hi there, im creating an online shop. I have made a product class (product bean) that is instanced every time the user wants to add a product to their cart. I have created a ShoppingServlet that handles the add, delete, view cart etc business logic therefore i use the product class in this servlet.  Eventhough the Product class is in the same directory as the ShoppingServlet the compiler does not resolve the symbol Product in (Product p = ...).

I have tried using a package, including it in the classpath but still no luck.  I must have a config prob somewhere but iv checked couple of times.

May be u can help me?
Question by:puntee
  • 3
  • 2
  • 2
  • +1
LVL 86

Expert Comment

ID: 10768356
Is either of the classes in a package? Make sure there are no conflicts with other Product that could be in the classpath
LVL 14

Expert Comment

by:Tommy Braas
ID: 10768436
Did you use an IDE to create the Java files?

Author Comment

ID: 10768732
yeah i used an ide
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

LVL 86

Accepted Solution

CEHJ earned 100 total points
ID: 10768780
Then make sure Product is added to the project or whatever your IDE calls it (probably through the menu)
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 100 total points
ID: 10768917
Thanks for the abundance of information in your response.

Look at the classpath used for the compiler in your IDE, as I am assuming that compilation works fine there. Also, there might be console output from the IDE that tells you exactly how your Java files were compiled.
LVL 86

Expert Comment

ID: 10768968
>>Look at the classpath used for the compiler in your IDE

Oh yes - i forgot - you're going from IDE to command line. That's absolutely right. IDEs tend to build their own, often sizeable, classpaths
LVL 30

Expert Comment

by:Mayank S
ID: 10772026
Yeah, if you're compiling from the command-prompt, you should see that the classes are there in the class-path of your system (because IDEs don't use system-classpath).

You can set the class-path this way: set classpath=%classpath%;c:\myfolder\....;.

// c:\myfolder\.... -> contains the .class files that you need

-> if you have the classes in a package, then set the classpath only till the parent directory of the package-folder

More on classpath: http://www.mindprod.com/jgloss/classpath.html

Which IDE are you using, BTW?
LVL 30

Expert Comment

by:Mayank S
ID: 10958610
Split: CEHJ and orangehead911

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
map related example 6 55
Groovy problem when using SOAPUI : DispatchException occurred 7 58
servlet example 17 51
collection output issue 9 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question