aspose file tools*
The moose likes Beginning Java and the fly likes how do i import a compiled file in current file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how do i import a compiled file in current file" Watch "how do i import a compiled file in current file" New topic
Author

how do i import a compiled file in current file

roomy iqbal
Greenhorn

Joined: Oct 23, 2008
Posts: 7
Hi

Thanks guys you have been very helpful in last problem now i have got another problem. I have got 2 files Book.java and ShoppingServlet.java. I have compiled Book.java and it has generated a class file. Shopping sevlet uses Book.java items. here is how the code looks like

Book.java


ShoppingServlet.java


Now when I execute this it gives me errors related to Book.java which is already compiled and its class file is available. I have tried to put it in -cp parameter as well here is the kind of error i get

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
You need to find where the Book class is. Are you used to compiling classes with a package declaration?

If you search through beginners' you find old threads.
  • This one, where somebody else seems to have the same problem.
  • This one where the late Stan James (instanceof SideKick) links to a tutorial about packages.
  • Somebody who had a very simple answer to compiling two files.
  • At least two ways to compile files in packages.

  • Make sure you have the servlet packages installed. Try compiling both files simnultaneously. Tell us whether it worked.
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24166
        
      30

    Also note that within a package "ebookshop", it is not not only unnecessary to import any other class in package ebookshop, but in fact it might be part of the problem you're having. The import statement doesn't belong there at all.


    [Jess in Action][AskingGoodQuestions]
    roomy iqbal
    Greenhorn

    Joined: Oct 23, 2008
    Posts: 7
    thanks i managed to fix it using the links that you guys provided. I just compiled them together and it worked

    javac -Xlint Book.java SoppingServlet.java
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36508
        
      16
    Well done
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: how do i import a compiled file in current file
     
    Similar Threads
    unable to compile servlet
    Compile Question/Error
    which are the main packages to import while writing a strut app?
    Compiling custom imports
    package problem