Importing other package java classes

I am doing a webapp using Tomcat .I have some classes which i want to use in another webapp.I did set the PATH variable to point to the my first webapp classes directory .But it is still not bale to locate the classes.
Does anyone have any idea.

Learn how the Tomcat class loaders work and how to deploy Web apps properly.
PATH doesn't affect Java at all. That's an OS environment variable. If you meant CLASSPATH, that'll do you no good, either, because Tomcat ignores any CLASSPATH environment variable.
Read up on the Tomcat CLASSPATH. It's important.
If you want both apps to use those .class files you have a few alternatives:
(1) Put those classes in a JAR file and put that in the TOMCAT_HOME/common/lib directory.
(2) Put those classes in a JAR file and put copies in the WEB-INF/lib directory for both apps.
(3) Copy those .class files into the WEB-INF/classes directory for both apps.
I'd prefer (2) myself.

Similar Messages

  • Cannot import custom made java class

    Hello
    I wrote a java class say (Money.java) which compiled fine. When I was importing it to another class (Account.java), the folowing error message appears:
    Account.java.1:'.' expected
    import Money;(an errow pointing to ";")
    I dont think the code is wrong, because when I cut and attach the Money class code to the front of the Account class it compiled successfully.... I am confused! I wrote the import command according to the text book as follows:
    import Money;
    public class Account
    By the way, both the Money and Account classes are saved in the save folder... How come it wont let me import...
    Looking forward for an early reply.
    Thanks

    In older versions of Java, it was possible to import classes from the default package using a statement like:
    import Money;
    This feature has been removed from Java as of version 1.5. You cannot import classes from the default package.
    Note that if your other code (Account.java) is also in the default package, you do not need to import the class Money. Just remove the import statement.
    If class Account is in a different package and you want to use class Money, then the only option you have is to put class Money in another package than the default (unnamed) package.

  • EJB DC, where to put other public java classes?

    I'm wondering what the best way to structure my code is, in this context:
    I have an EJB DC that utilizes some custom Java classes that need to be available to clients.  For example, the business methods in the EJB may return instances of said custom code classes. 
    By default, the EJB DC contains a compilation public part called 'client', but you can't add any other entities to it, as you'll remove the default entity.  I could manually create the entities in the public part, but I think when I add another EJB to the DC, it will overwrite the entities that I've created....either that, I'm messing with the default config, something I'm not interested in doing. In fact, this [page indicates that you should NOT alter the generated PPs:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/02/6755bd296ade42931646f869b1fd15/frameset.htm
    So, what's the best way to handle this situation?  I can create another public part, but that means that when someone wants to use the EJB's, they have to create two usage relationships - one to the EJB, and one to the PP that contains the helper classes.  I think that this is the only way to do it, however.
    How have other folks handled this common situation?

    Hi Ken,
    I think you've found it.
    I'm not so sure about DC projects, but in the plain J2EE case I would recommend to put all common (public) classes in a separate component (application library) and make references to it both from the EJB application as well as from its clients. This library would also contain the EJB interfaces, so there would not be a need for direct reference from the clients to the EJB application.
    I think with DC public parts you are achieving almost the same.
    Cheers,
    Vladimir
    PS: BTW, probably you would be able to get more thoughts on this in the SAP NetWeaver Development Infrastructure (NWDI) forum.
    Message was edited by:
            Vladimir Pavlov

  • Compile class in package that imports other package

    hi,
    i prepared two packages asume with name x_pck and y_pck.
    a class in x_pck imports a class in y_pck. when i try to compile the class in x_package javac gives error such it can not find y_pck. so where do i have to put my packages to make javac see them?
    thanks...

    ok i found the solution.
    i use javac with parameter "-classpath" such like:
    javac -classpath path_of_y_pck path_of_class_in_x_pck

  • What are the two packages default imported into all Java classes?

    I just remember one of it is java.lang.* ... What are the others? Thanks for any replies. ^v^

    http://java.sun.com/docs/books/tutorial/java/interpack/usepkgs.html
    For your convenience, the Java compiler automatically imports three entire packages:
    The default package (the package with no name)
    The java.lang package
    The current package by default

  • How to import other package into Dictionaries in nwds web dynpro project

    Hi
        i'm learning JA312, in some topic, there need a method declaration in component controller, the method like this:
      public void showContext(IWDContext context),
       i can add method in method tab in component controller,but can not add parameter of IWDContext types,because in Dictionaries,there are only com.sap.ide.., and not include com.sap.tc.webdynpro.progmodel.api.
    so,how to import package into Dictionaries, for example com.sap.tc.webdynpro.progmodel.api.
    a step by step article is preferred. thank you

    choose "Java Native Type".

  • Import java class from model package

    I have a java class in model package.I create a managed bean in the view package and I want to import the first java class with "import model.class1" but this error "import model.class1 not found" is shown.What should I do?

    Hi,
    Why are you importing the Model classes to your backing bean? You should not be doing that. Instead, expose the method in model as client interface (whichever you want to call in the backing bean), create the method binding in your pagedef. Then, from the backing bean, you can execute the method programatically.
    -Arun

  • Importing Java Class Question

    Hello,
    Sorry for such a newbie question and such a long post, I did remember how to do this before but now I can't for the life of me remember. Anyhow, I have a simple question about importing custom-made java classes, from another directory in the windows operating system. I have the classpath set, and also I realize that because the two files below are in the same directory theres no need for an import statement as Java will look for the class in the same directory.
    But I would like to know how the import statement is suppose to look to import a custom made java class from another directory, (assuming of course that I set the correct classpath)
    here's the java class location:
    c:\school\csc365\narcus.java
    //narcus.java
    import java.io.*;
    class narcus implements Comparable
    String firstName = "firstName";
    String lastName = "lastName";
         public narcus()
         firstName = firstName;
         lastName = lastName;
         public narcus(String f)
         firstName = f;
         lastName = lastName;
         public narcus(String f, String l)
         firstName = f;
         lastName = l;
    public String getFirst()
    return "first..";
         public int compareTo(Object e)
         return 1;
    Here's the location of the driver program thats suppose to use the narcus.java class
    c:\school\csc365\test.java
    //test.java
    //import statement? maybe import "c:\\school\\csc365\\*"; ?
    import java.io.*;
    class test
    public static void main(String[] args)
         narcus jim = new narcus();
         System.out.println("omg\n");
         System.out.println(jim.getFirst());
    And also, here is my classpath:
    PATH=c:\school\csc365\;c:\school\
    The classpath also points to the jdk libraries and few other directories but I didn't write that above, as it probably isn't relevant.
    I've tried the following import statements.
    import "c:\\school\csc365\\narcus.java";
    import "narcus.java";
    import "c:\\school\\csc365\\*";
    But I keep getting an error that says:
    test.java:1 <identifier> expected
    Any help is appreciated!

    Hi Folks,
    I am new to this forum, heard that interesting discussions always happens on this forum so immediately registered,don't want to miss any oppurtunity to participate in discussions.
    I have pretty much basic question regarding compiling and exceuting files in different packages.I have the following directory structure
    C:\Projects\WDPROEast\Development\CommonService\Code\Java from where java files stored in different packages as follows:
    com\wdpro\commerce\common\crm\dae\nautilus\adapter directory has java files in com.wdpro.commerce.coomon.crm.dae.nautilus.adapter package.
    com\wdpro\commerce\common\dae\exception has java files with package named com.wdpro.commerce.common.dae.exception.
    com\wdpro\commerce\common\dls\exception has java files with corresponding package name.
    com\wdpro\commerce\common\dto has java files under proper package name.
    com\wdpro\commerce\common\exception has java files with appropriate package name.
    com\wdpro\commerce\common\util has java files with package name. I am starting at Java Directory,want to compile and run file named a.java in com.wdpro.commerce.coomon.crm.dae.nautilus.adapter package with having all other java files on classpath as follows
    so I issued command for compilation as follows C:\Projects\WDPROEast\Development\CommonService\Code\Java>javac com/wdpro/commerce/common/crm/dae/nautilus/ada
    pter/a.java com/wdpro/commerce/common/crm/dae/nautilus/adapter/NautilusServiceUtility.java com/wdp
    ro/commerce/common/crm/dae/nautilus/adapter/URLReader.java com/wdpro/commerce/common/crm/dae/nautilus/adapter/
    b.java com/wdpro/commerce/common/dae/exception/*.java com/wdpro/commerce/common/dto/*.java
    com/wdpro/commerce/common/exception/*.java com/wdpro/commerce/common/util/*.java com/wdpro/commerce/common/dl
    s/exception/*.java It compiled greatly but when I issue command to run a.class file as
    C:\Projects\WDPROEast\Development\CommonService\Code\Java>java com/wdpro/commerce/common/crm/dae/nautilus/adap
    ter/UtilityAccesssit's giving following exception
    Exception in thread "main" java.lang.NoClassDefFoundError: com/wdpro/commerce/common/crm/dae/nautilus/adapter/
    UtilityAccesssbut when I run a.java with the following command
    C:\Projects\WDPROEast\Development\CommonService\Code\Java>java com/wdpro/commerce/common/crm/dae/nautilus/adap
    ter/UtilityAccess com/wdpro/commerce/common/crm/dae/nautilus/adapter/NautilusServiceUtility.java com/wdpro/com
    merce/common/crm/dae/nautilus/adapter/URLReader.java com/wdpro/commerce/common/crm/dae/nautilus/adapter/Nautil
    usAccessUtility.java com/wdpro/commerce/common/dae/exception/*.java com/wdpro/commerce/common/dto/*.java com/w
    dpro/commerce/common/exception/*.java com/wdpro/commerce/common/util/*.java com/wdpro/commerce/common/dls/exce
    ption/*.javaSo my question do I need to add all required java files to path when required class files are under different packages?is it manadatory.
    I hope you understand my question,pass me any comments you may have.
    Thanks alot,
    Anu

  • Importing java class from forms 6i

    Dear people
    I want to import very simple java class from forms 6i, i went to programs then i choose import java classes, then it gives me error message PDE-UJ1001 failed to create the jvm.
    please tell me how to solve the problem.
    Yasser

    +... not a Java question. Post moved from the New To Java to the Forms forum.+

  • Import only Java classes

    Hi,
    I've got a export dump (with rows=N) and now I would like to import only the JAVA CLASSES/RESOURCE from this export dump .
    Can someone please assist in the procedure to follow?
    Thanks.

    I dont believe that you can specifically ask for java classes to be imported with imp. You can with datapump import.
    You could do an import with the indexfile parameter and look at the DDL that would have been run, and pick out your java classes out of this?

  • Import Statement in Java

    I have one question about import of packages and classes. If I import java.awt.** why can't all the packages starting with java.awt get imported.For example java.awt.color.* or java.awt.font doesn't get imported. I didn't get why so and if so then why these classes were prefixed with java.awt. Same case happened to me when I imported java.util.* and didn't find java.util.concurrent.locks.Lock get imported. There must be some reason behind this. But I don't know. Can anyone please let me know ?
    --Prasad
    Edited by: Prasad_Kumbhare on Oct 1, 2007 7:55 PM

    flounder wrote:For me:
    Boredom, it gives me something to do.
    Reward at imparting my knowledge onto others. When I was at uni I got some part time work as a tutor helping 1st and 2nd year students with their prac sessions and tutorials. I enjoyed being able to mould young minds. Plus, with all the subliminal messages I planted, one day I will rule the world. OK that last bit wasn't true. I want to rule the universe!That's very noble Mr Flounder, so thanks again.
    I imagine if you want to rule the universe it makes sense to achieve this goal via a platform independant language. But does Java run on differant planets?
    S

  • System.out from Java class not output to JSP

    I am using JSP to make a Java API web accessible. I include (package) java classes that write error messages to standard out when they catch an error. Works fine on the command line. Problem occurs when using in JSP. I include them with a page directive (importing the package) rather than use them as beans, since they do so much more than beans do, and since I use many of the classes in a single page.
    i.e.
    <%@ page import="OPS.*" %>
    When errors occur, messages to "standard out" (system.out) don't appear in the html output of the JSP. I don't know where they are going (they aren't in the web server's error log), but they aren't going where I expected them to (browser window).
    I figured that standard out was the browser (httpServletResponse). Where am I going wrong here?
    Basically, I have a class that connects to a database (call it db) and does queries/updates. I have a class (call it employee) that uses the db class. I have a jsp page that instantiates the employee class and executes method calls. The code in the db class that outputs SQL error messages (db class instantiated by employee class) never gets put in the browser window. Nor in the server log, nor the console.
    How can I get system.out calls in classes db and employee to get output to the browser? The JSP outputs all other code and is not freezing nor not flushing the buffer.
    Thanks!

    I also use an Iplanet over which I have little control. But I can log on via telnet. If I log on (I use Reflection) and run my pages, the errors show in the Reflection window. If you have telnet access to the server, you might want to give this a try.
    Another alternative would be to add a few lines to your classes that allow you to pass a reference to the jsp StringWriter from your jsp and use that to output the errors to the browser.

  • How to use loadjava tool to regard file in other packages/JARs?

    How do I have to set the options for the loadjava tool when I have a Java class that uses classes of another package/JAR (which I have developed by myself). I thought it was just to create a JAR containing my Java class as well as the JARs containing the other packages/classes being imported in my Java class. and then:
    loadjava -u user/passwd@hostname:1521:xxx -v -r C:\Temp\MyJAR.jar
    but I always get
    cannot find symbol    :    class MissingClass

    This is the wrong forum!
    1. Repost the question in the Database JVM forum
    Java in the Oracle Database
    2. Edit this thread and post the link to the new one and direct people to follow up there
    3. Mark this thread ANSWERED so people will follow up in the other forum.
    When you post there provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION) and review Chapter 11 Schema Objects and Oracle JVM Utilities in the Java Developers Guide
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/cheleven.htm#CACFHDJE
    see '-recursivejars' in the Argument Summary section.
    >
    -recursivejars
    Normally, if the loadjava tool encounters an entry in a JAR with a .jar extension, it will load the entry as a resource. If this option is specified, then the loadjava tool will process contained JAR files as if they were top-level JAR files. That is, it will read their entries and load classes, sources, and resources.

  • Calling java class from SLSB

    I am trying to call a java class from SLSB . There are external jars which are imported in my java class . When i try to instatiate the java class in SLSB. It ia not able to access the external jars. It gives the following exception :
    0000002e ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "applyRules" on bean "BeanId(MDB_SLSBEAR#MDB_SLSB.jar#msgProcess, null)". Exception data: java.lang.NoClassDefFoundError: org.springframework.context.ApplicationContext
    My code is as follows :
    SLSB:
    package com.vsnl.ejbs;
    import com.vsnl.pricing.bizObjects.CustomizedRateRequest;
    import com.vsnl.pricing.bizObjects.RateRequest;
    import com.vsnl.pricing.dao.ARR.AutoprocsMain;
    import org.springframework.context.ApplicationContext;
    * Bean implementation class for Enterprise Bean: msgProcess
    public class msgProcessBean implements javax.ejb.SessionBean {
    static final long serialVersionUID = 3206093459760846163L;
    private javax.ejb.SessionContext mySessionCtx;
    * getSessionContext
    public javax.ejb.SessionContext getSessionContext() {
    return mySessionCtx;
    * setSessionContext
    public void setSessionContext(javax.ejb.SessionContext ctx) {
    mySessionCtx = ctx;
    * ejbCreate
    public void ejbCreate() throws javax.ejb.CreateException {
    * ejbActivate
    public void ejbActivate() {
    * ejbPassivate
    public void ejbPassivate() {
    * ejbRemove
    public void ejbRemove() {
    public void applyRules(CustomizedRateRequest customizedRateRequest){
    System.out.println("RR ID in SLSB***"+customizedRateRequest.getProductCustomerId());
    System.out.println("RR ID in SLSB$$$"+customizedRateRequest.getIsDestFlag());
    try{
    System.out.println(" before the callng of commented function ");
    AutoprocsMain autoprocsMain = new AutoprocsMain();
    System.out.println(" after making instance ");
    //autoprocsMain.applyRules(customizedRateRequest);
    catch(Exception e){
    e.printStackTrace();
    My Java Class:
    package com.vsnl.pricing.dao.ARR;
    import java.io.InputStreamReader;
    import java.io.Reader;
    import java.util.ArrayList;
    import java.util.List;
    import com.vsnl.pricing.dao.ARR.Base;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.apache.log4j.Logger;
    import org.drools.FactHandle;
    import org.drools.RuleBase;
    import org.drools.RuleBaseFactory;
    import org.drools.WorkingMemory;
    import org.drools.compiler.PackageBuilder;
    import org.drools.rule.Package;
    import org.springframework.context.ApplicationContext;
    import com.vsnl.pricing.bizObjects.Customer;
    import com.vsnl.pricing.bizObjects.RateRequest;
    import com.vsnl.pricing.interfaces.ARR.IARRDAO;
    import com.vsnl.util.VSNLLogger;
    import com.vsnl.pricing.bizObjects.InnerObject;
    import com.vsnl.pricing.bizObjects.CustomizedRateRequest;
    public class AutoprocsMain extends Base{
    private static Log log=LogFactory.getLog(AutoprocsMain.class);
    private static Logger logger = Logger.getLogger(Invoker.class);
    ApplicationContext ctx;
    //ApplicationContext ctx;//=configure();
    IARRDAO autoprocsDAO;//=(IAutoprocsDAO)ctx.getBean("autoProcDAOTarget");
    public AutoprocsMain() {
    System.out.println(" inside the Autoproc constructor");
    //VSNLLogger.debug(logger, "before creatiom of CTX");
    //System.out.println(" before creation of CTX ");
    try{
    //System.out.println(" inside the Autoproc constructor");
    ApplicationContext ctx=configure();
    autoprocsDAO=(IARRDAO)ctx.getBean("arrTarget");
    catch(Exception e)
    //VSNLLogger.error(logger, e.getMessage());
    //VSNLLogger.debug(logger, "after creation of CTX");
    //System.out.println(" after creation of CTX ");
    public void applyRules(CustomizedRateRequest customizedRateRequest)throws Exception{
    RateRequest rateRequest=new RateRequest();
    List rateRequestObjs= new ArrayList();
    List<CustomizedRateRequest> CustomizedRateRequestObjs=new ArrayList<CustomizedRateRequest>();
    try{
    //rateRequest= autoprocsDAO.getRecord();
    rateRequestObjs=autoprocsDAO.getAllRateRequests();
    //VSNLLogger.debug(logger, " AFTER THE CALL OF getAllRateRequests() function ");
    CustomizedRateRequestObjs=autoprocsDAO.getCustomizedObjects(rateRequestObjs);
    catch(Exception e)
    //VSNLLogger.error(logger, e.getMessage());
    RuleBase ruleBase=readRule();
    WorkingMemory workingMemory = ruleBase.newStatefulSession();
    FactHandle handle =workingMemory.insert(customizedRateRequest);
    //customizedRateRequest.setContinueRule("1");
    workingMemory.fireAllRules();
    if(CustomizedRateRequestObjs.size()>0)
    FactHandle handle =workingMemory.insert(CustomizedRateRequestObjs.get(0));
    for(int i=0;i<CustomizedRateRequestObjs.size();i++)
    CustomizedRateRequest customizedRateRequest=CustomizedRateRequestObjs.get(i);
    customizedRateRequest.setContinueRule("1");
    workingMemory.modifyInsert(handle,customizedRateRequest );
    workingMemory.fireAllRules();
    System.out.println(" after the firing of all rules ");
    public static void main (String args[])
    AutoprocsMain procsMain = new AutoprocsMain();
    try{
    procsMain.applyRules();
    catch(Exception e)
    e.printStackTrace();
    private static RuleBase readRule() throws Exception {
    System.out.println(" ****** inside readrule &&&& ");
    //read in the source
    Reader source = new InputStreamReader( AutoprocsMain.class.getResourceAsStream( "/Sample.drl" ) );
    // Reader source1 = new InputStreamReader( AutoprocsMain.class.getResourceAsStream( "/com/vsnl/resources/Sample2.drl" ) );
    //Reader source = new InputStreamReader( AutoprocsMain.class.getResourceAsStream( "/com/vsnl/resources/CustomerDiscount.drl" ) );
    //optionally read in the DSL (if you are using it).
    //Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
    //Use package builder to build up a rule package.
    //An alternative lower level class called "DrlParser" can also be used...
    System.out.println(" after package builder ");
    PackageBuilder builder = new PackageBuilder();
    System.out.println(" after package builder ");
    //this wil parse and compile in one step
    //NOTE: There are 2 methods here, the one argument one is for normal DRL.
    builder.addPackageFromDrl( source );
    System.out.println(" after add package source");
    //builder.addPackageFromDrl(source1);
    System.out.println(" after add package source1");
    //Use the following instead of above if you are using a DSL:
    //builder.addPackageFromDrl( source, dsl );
    //get the compiled package (which is serializable)
    Package pkg = builder.getPackage();
    System.out.println(" after get package ");
    //add the package to a rulebase (deploy the rule package).
    RuleBase ruleBase = RuleBaseFactory.newRuleBase();
    ruleBase.addPackage( pkg );
    System.out.println(" end of read rule function");
    return ruleBase;
    public IARRDAO retBean()
    return null;
    }

    Hi i am new to EJB .
    please explain me the problem ..and kindly tell me to how to add this in classpath. I am using webSphere application server.
    I added this in the classpath in the startup script.
    I also added all the required jars in the EAR libraries ( I am using the RAD IDE).
    Please help.

  • Getting The SAP KM data in a java class

    Hi Everyone
                    I want to get  the SAP KM data to a simple java class......I am able to get this with servlet but i want not a servlet but a simple java class that can get the Documents stored in SAP KM repository..................
    I am thinking of using any java Driver in some code like
    Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
                        String url = "http://host name :port";
                        Connection con = DriverManager.getConnection (url, "", "");
                        Statement stmt = con.createStatement ();
                   IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
                   ResourceContext c = new ResourceContext(serviceUser);
                   IResource r = ResourceFactory.getInstance().getResource(RID.getRID("/documents/Public Documents/"), c);
                   System.out.println("Current user   "+r.getContext().getUser().getDisplayName());
                   System.out.println("Current user  : "+r.getContext().getUser().getDisplayName());
                   System.out.println("Access RID  : "r.getAccessRID().toString()"<br>");
    But the above code is giving an exception---java.sql.SQLException: No suitable driver
    Can anyone tell me the suotable Lava driver to access SAP KM repository..Or any simple java code that can connect to SAP KM...
    Waiting for Ur reply
    Thanks & Regards
    Rupesh

    Is there a way to find the list of imports that a
    java class file has added.Yes. It's very easy. The answer is [url http://en.wikipedia.org/wiki/Mu_%28negative%29]Mu.

Maybe you are looking for