• 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

how to Import a program from another folder

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i have 2 program in different folder


program1.java exists in below folder

/usr/local/apache-tomcat/webapps/Asianet/WEB-INF/classes/com/example/servlets/program1

program1.java



program2.java exists in below folder

/usr/local/apache-tomcat/webapps/Asianet/WEB-INF/classes/com/example/program2


Error:

package com.example.servlets does not exist
import com.example.servlets.*;
^
i getting above error i cannot find what error guide me

[edit]Add code tags. CR[/edit]
[ August 19, 2008: Message edited by: Campbell Ritchie ]
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set the classpath to include the folder where your "com" folder is located. That would be /usr/local/apache-tomcat/webapps/Asianet/WEB-INF/classes in your case.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Rob says, you need to include the folder in the classpath, probably best done with the -cp option on javac and java. Go to this documentation page and click on "javac" and "java" for more details.

And please find the Code Tags; I have added them to your post so you can see how much easier it is to read.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic