Running Class in package?

I have problem running class in package. What do I write (win) to make the class in a packege run? If I remove it from the package I just write: java MyClass.

If it is in package com.bananaco, for example, then at
the command line you must type
java com/bananaco/MyClassI'd refrain from calling it that way, as it leads to confusion.
The standard way is to call it fully qualified
java -cp <classpath> com.bananaco.MyClass
under any JAVA release with the classpath set appropriately (rename <classpath> with yout path to directory where com is located in exmpale above).
Take in mind that the directory structure should reflect the package structure (having MyClass.class under com/banaco in the class path)
Oliver
>
That works for Java 2, but I sort of recall that for
Java 1 you had to use
java com.bananaco.MyClass
instead. So try both. And if you get NoClassDefFound
error, remember that the package has to be in
your classpath, not the class.

Similar Messages

  • How to call my own class in package B from a servlet in package A?

    Hi, I am trying to call a class in my serlvet, but the class is in a different package than my servlet, i.e., my servlet is in package A, and the class my servlet calls is in package B. I created a .jar for all files in package B, put the jar file in %JAVA_HOME%/jre/lib/ext, and set classpath to %JAVA_HOME%/jre/lib/ext. I can compile my servlet, but when I run it with Tomcat 4.0, it says that the class in package B is not defined (NoClassDefinitionError).
    Can anyone help? Thanks a lot.

    I set JAVA_HOME to c:\j2sdk1.4.0.
    All classes in package B are in one jar file, and all classes in package A are under CATALINA_HOME\webapps\ROOT\WEB-INF\classes. Do I need to create another jar file for package A or should I put package A in the same jar file as package B?
    I tried to put the jar file under WEB-INF\lib, but it still failed.
    The project is the first time for me to use servlet, so I am not very familiar with it. I am wondering if there is any configuration file I need to modify for the servlet I wrote?
    Thanks for the help.

  • Import class without package

    hellow, i have a web aplication named test , and i have a class named conexion
    when i import a package "pack" with the class conexion, not problem (test/WEB-INF/classes/pack/conexion.class) <% import="pack.* " %> but when i have only the class conexion WITHOUT package (test/WEB-INF/classes/conexion.class) and i import <%import ="conexion" %> i have problem ("The import conexion cannot be resolved") and when i not import the class i have problem (conexion cannot be resolved to a type) , my question is:
    how to i import a class without package in JSP , and if the test/WEB-INF/classes is in the classpath when compile the servlet , why the tomcat not found the class conexion?
    (tomcat 5.5.20 , jdk 1.5.09 , vim)
    thank
    (Sorry my english , i'm from Chile)

    Hi I am hosting my JSP application with Resin 2.17 which uses classes directly in JSP code (not packages). To make this work I had to specify the classpath in Resin.conf and it worked.
    My problem is getting this to work with TomCat or any other application server that will allow me to debug my project in Eclipse or NetBeans IDE. (I have yet to find an IDE that Supports debugging JSP/Java code running on Resin - so I want to switch my application server but I am not sure how to configure my classpath for the application servers to look for java classes in the specified directory just like I did with Resin.

  • Class and package names

    I'm novice in Java, but not novice in programming. So, it is not a problem to understand and to write simple samples, but it is still hard to create a good package structure and give good names for classes.
    For example now, I started writing simple standalone application, which will be run by cron and will communicate with 2 webservices. I will receive data(reports) from one webservice, and will send this data to another one. From the very beggining, I have a poblem about structure of roject and naming. Is it ok, to make only one class, with name for example ReportApp? Or better create one class for communicating with first service, another - with second, and main class will call methods of this classes? Also package name... I think it is good, when from package you see, that i is service, or xml.util etc. How can I show in package name that it is batch standalone application? Can somebody explain what names for classes and packages he'll use for such task, please.

    Descriptive names are nice....
    For packages, a standard method is a domain name for your company or organization:
    com.widgetsRus.service.
    com.widgetsRus.ui.
    com.widgetsRus.util.
    As for class names, just descripe what the class is for. ReportServer, ReportClient, Report (interface), AbstractReport (implements Report), StatusReport (extends AbstractReport), etc...
    As for creating a class for this and that, or separate classes, that's a design issue, but typically, it's easier to maintain things if they are kept in smaller classes with related functionality.

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • How to organize j2me classes into packages?

    Hello!
    I'm using Wireless Toolkit 2.5.2 and I have got a question about it.
    Does anybody know, how to organize j2me classes into packages?
    As far as I know, all source files should be placed inside WTK_home_directory\apps\my_project\src folder.
    Although it is possible to create arbitrary folder structure (for example, src\com\my_company\www\my_package) and successfully compile the project,
    it's not possible to run it on the emulator or any target device. Trying to do it, I get ClassNotFound exception.
    It's not surprisingly, because virtual machine on the device doesn't know, where to look for desired classes.
    So the question is how to add new entries to the device classpath (of course, if it exists)?
    And is it possible to configure it through application descriptor (jad) file somehow?
    Any ideas, references, descriptions?
    Thanks in advance,
    A.

    Hello!
    So, I have found the solution and this question is not actual any more.
    The solution is quite simple - you have to properly configure application jad-file.
    It can be done like this (in ktoolbar):
    1. Open project settings from main menu (Project - Settings).
    2. Then go to MIDlets tab.
    3. There you have to change value in "*class*" column (for example, to smth like this - com.my_company.www.my_package.my_midlet_class_name).
    4. Press Ok button.
    Having done these steps, you will be able to have any package structure you need
    (because after it AMS on the device will know where to look for your application class files).
    A.

  • How do i put classes in package in NetBean Environment

    Hello,
    I install NetBean IDE for developing website using JSP and Servlet. I am using Internal Tomcat provided by this IDE.
    Problem is this i put java classes in the Class folder of Web-INF folder, but i am not able to access these classes from JSp page.
    I try to put these classes in Package but even though i use package option IDE does not put classes in the package.
    I am using internal compiler provided by this IDE for compiling java class' source file.
    What should i do, please help me
    Thank you

    hai
    i have the same problem to finding the classes in package...
    in my case i know the jars name and i have loaded
    classes using code
    ResourceBundle bundle = ResourceBundle.getBundle("source\\ClasssPath");
    StringTokenizer stToke = new StringTokenizer(bundle.getString("ClassPath"),";");
    String temp;
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    while(stToke.hasMoreTokens())
         temp = stToke.nextToken().trim();
    if(temp.endsWith(".jar"))
    JarFile jar = new JarFile(new File(temp));
         Enumeration en = jar.entries();
         String pathStr;
         while(en.hasMoreElements())
         pathStr = en.nextElement().toString();
         System.out.println("pathStr ="+pathStr);
         if(pathStr.endsWith(".class"))
              System.out.println( classLoader.getResource(pathStr));
              System.out.println(classLoader.loadClass(pathStr.substring(0,pathStr.indexOf(".class")).replace('/','.').trim()));
         else classLoader.loadClass(temp);
    here i am getting the classes in that package using code
         String[] filLis = new File("//it//sella//converter//ptlf//startup//").list();
         int length = filLis.length;
         while(length-- >0)
         System.out.println(">"+filLis[length]);
    but its returnign the class when this classes in locale folder(i.e)its not getting the classes in loaded memory...
    so how to retrieve the class files names using package structure name...
    (i am having more then 20 jars files, inthat inside the jar samepackage structue may appear in more then one jars )
    pls help me in this field..
    Thanx

  • Error while running legal consolidation package RUNCONSOL

    Hi All
    I have below error while i run the consolidation package can anyone throw light on the same
    Start time --->5:17:46 PM  -  Date:1/6/2009  (build code:254)
    User:BPCDEV\bpcadmin
    Appset:FTIL
    App:LEGALAPP
    Logic mode:1
    Logic by:
    Scope by:
    Data File:
    Debug File:D:\BPC\Data\WebFolders\FTIL\LEGALAPP
    ..\AdminApp\LEGALAPP\LegalConsolidation.txt
    Logic File:D:\BPC\Data\WebFolders\FTIL\LEGALAPP
    ..\AdminApp\LEGALAPP\LegalConsolidation.lgx
    Selection:D:\BPC\Data\WebFolders\FTIL\LEGALAPP\PrivatePublications\bpcadmin\TempFiles\FROM_81_.TMP
    Run mode:1
    Query size:0
    Delim:,
    Query type:0
    Simulation:0
    Calc diff.:0
    Formula script:
    Max Members:
    Test mode:0
    Is Modelling:1
    Number of logic calls:1
    Call no. 1, logic:D:\BPC\Data\WebFolders\FTIL\LEGALAPP
    ..\AdminApp\LEGALAPP\LegalConsolidation.lgx
    Building sub-query 1
    Query Type:0
    Max members:
    Executing SPRUNCONSO [LEGALAPP], [ACTUAL], [C_FTILG], [SPSCOPE_200127],[SPLOG_282986]
    SPRunConso Version 2.06
    ERROR CSD-015 No instruction retreived from the ELIM Table with FLOW Dimension
    Time to run stored procedure:1.6 sec.
    call 1 completed and data posted in 1.6 sec.
    Run completed in 1.8 sec.
    End time --->5:17:48 PM  -  Date:1/6/2009
    SPRunConso Version 2.06
    ERROR CSD-015 No instruction retreived from the ELIM Table with FLOW Dimension
    Thanks and Regards
    Harish B K

    Hi this was due to not maintaining proper design and it was solved later once we setup all the parameters perfectly
    and had time dimension members for one year prior (though seems strange)

  • SSIS Package runs from the Package executer and from BIDS but not from the sql agent schedular

    Hi Experts,
    I have 2 packages :
    1. Main Package -For each loop package
    2. Sub Package - As we need to collect the information from several other DB with same table structures .
    The Main Package calls the Sub Package and loops through several linked server (9 of them ) .
    From last 2 weeks the scheduler is running on time but no data is loaded into our destination DB . 
    Daily i need to manually run the package .
    The SQL Agent task is scheduled using the service account from which  the sql server was installed on the server so it has the full privledges.
    If i run the Main package from the BIDS i see 2 messages related to the configuration of xml no error message and executes fine.
    If i run the Package from the execute package utility it runs fine.
    Now if the package is scheduled for a nightly load it executes fine successfully no error message also in the Job History
    but when i check for the data loaded on that day no data loads up in the destination DB . Due to this behavior of the sql agent even if am on leave i have to login on to the server and exec manually so if at times i forget the exec we are in big trouble
    Please experts help me in troubleshooting the issue.
    Thanks
    Priya

    Hi Visakh16 ,
    We are using a service account to run the package .. Earlier in the BIDS i was getting the error crypotgenic
    something password .. I googled out and changed the security : Protection Level : Dont save Sensitive
    information . So that error now its not showing in the BIDS
    And how is login mapping done for the linked servers?  You've configured a mapped login for the service account also?
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Please help with this issue "To Run a SSIS Package outside of Server Data Tools You must install Drived Column of Integration sercvies of higher" From C# app

     i have searched all over the google and here on MSDN(I have read all the threads related to my problem ) , i am new to SISS and doing my clg project ,
    I have this package which loads data from  dim tables to a fact table , my Package runs without any problem in BIDS (2012)
    I have installed SQl Server integration services on SQL and service is also running in services.msc,
    the problem comes when i execute my package using my C# application i am using MSDN Method to execute a SSIS package programmatically given here.
    "http://msdn.microsoft.com/en-us/library/ms136090.aspx"
    For loading my FactTable i have used a Derived columns  and some lookups , 
    Now if i don't use derived columns and looks ups and just use source and destination component then my package runs fine from my C# application but if i use derived columns or looks ups etc it gives the following error
    "Error in Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline: To Run a SSIS package outside of SQL Server Data Tools you must Install Derived Column of Integration services of higher"
    I am searching and trying to resolve this issue from previous 2 days but without any luck please help or guide me what is solution to this problem ,,i will be very thankful
    I have also found that integration services that are running on my system have version  10.0
    but the BIDS have version Version 11.0.3402.0
    IS this causing problem ?  if yes then what i have to do  ?

    Hi BlaxButt,
    The package is developed in SSDT installed by SQL Server 2012, so it is a SSIS 2012 package. However, the Integration Services you have installed is SQL Server 2008 R2 version. To run the package outside SSDT, you need SSIS 2012 installed. The reason why
    the package runs fine with only Source and Destination components is that such a simple package can be executed by the DTExec utility installed by SQL Server 2012 Data base Engine or Client Tools (SQL Server Import and Export Wizard). To run a package that
    uses other tasks/components outside SSDT/BIDS, the SSIS runtime is also required except the DTExec utility. To obtain the SSIS 2012 runtime, we have to install SSIS 2012 on the server where the package runs.
    Reference:
    http://stackoverflow.com/questions/19989099/getting-error-running-ssis-package-on-non-ssis-server
    Regards,
    Mike Yin
    TechNet Community Support

  • Getting an error running an SSIS package from SQL server agent

    This is the first time I'm running an SSIS package in SQL server agent.
    I'm running a SQL server agent job and getting this error message:
    Am I using the correct options? (options list below)
    Message
    Executed as user: SITEX\stxdatasqlexec. Microsoft (R) SQL Server Execute Package Utility  Version 10.50.1600.1 for 32-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  1:42:00 PM  Error: 2014-04-17
    13:42:01.01     Code: 0xC0011007     Source: {B72BF421-785A-44EC-9570-D2A40B046CA7}      Description: Unable to load the package as XML because of package does not have a valid XML format. A
    specific XML parser error will be posted.  End Error  Error: 2014-04-17 13:42:01.02     Code: 0xC0011002     Source: {B72BF421-785A-44EC-9570-D2A40B046CA7}      Description: Failed
    to open package file "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx" due to error 0x80070003 "The system cannot find the path specified.".  This happens when loading a package and the file cannot be opened or loaded correctly
    into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  End Error  Could not load package "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx"
    because of error 0xC0011002.  Description: Failed to open package file "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx" due to error 0x80070003 "The system cannot find the path specified.".  This happens when loading a
    package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  Source:
    {B72BF421-785A-44EC-9570-D2A40B046CA7}  Started:  1:42:00 PM  Finished: 1:42:01 PM  Elapsed:  0.047 seconds.  The package could not be found.  The step failed.
    Here are the options I'm using:
    package source - file system
    data source  destination = my SQL server db
    execution option - use 32 bit runtime
    command line entry:
    - /FILE "C:\Users\halexandrovich\Documents\Nbr_Rolls_base.dtsx"  /CONNECTION DestinationConnectionOLEDB;"\"Data Source=esxdspr-sql01.sitex.com;Initial Catalog=SuesTbls;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=false;\""
    /CONNECTION SourceConnectionFlatFile;"\\sitex.com\dfs\Production\SFTPData\LPSEFTProcess\FromAADFS\Rpt_Nbr_Rollsperbatch_20140331_20_0.txt"
    /X86  /CHECKPOINTING OFF /REPORTING E
    I checked the filename so it must be the XML format it's complaining about.

    Thank you, pituach.
    I tried running the package using just my c drive without partition, C:\Nbr_Rolls.dtsx, but still getting the same
    error. I do not see any option on this site to post my package. I know it's not the path that's the issue. Our support desk already fixed that because I was getting a different message before.
    Message
    Executed as user: SITEX\stxdatasqlexec. Microsoft (R) SQL Server Execute Package Utility  Version 10.50.1600.1 for 32-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  11:23:00 AM  Error: 2014-04-18
    11:23:00.44     Code: 0xC0011007     Source: {2BEE62EB-DD08-4867-9F5C-660167964650}      Description: Unable to load the package as XML because of package does not have a valid XML format. A
    specific XML parser error will be posted.  End Error  Error: 2014-04-18 11:23:00.45     Code: 0xC0011002     Source: {2BEE62EB-DD08-4867-9F5C-660167964650}      Description: Failed
    to open package file "C:\Nbr_Rolls.dtsx" due to error 0x800C0006 "The system cannot locate the object specified.".  This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of
    either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  End Error  Could not load package "C:\Nbr_Rolls.dtsx" because of error 0xC0011002.  Description: Failed
    to open package file "C:\Nbr_Rolls.dtsx" due to error 0x800C0006 "The system cannot locate the object specified.".  This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of
    either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.  Source: {2BEE62EB-DD08-4867-9F5C-660167964650}  Started:  11:23:00 AM  Finished: 11:23:00 AM 
    Elapsed:  0.125 seconds.  The package could not be found.  The step failed.

  • Not allowed to import classes without package names?

    Hi,
    I have a few questions on Packages and importing?
    1. Is the following true that it is illegal to import classes in the same package as the current class, will this cause a comilation error? If this is the case where in the Java Language specification is this actually written as I could not find it?
    2. This has probably been answered by question 1 but if I have 2 classes in the same package and if I import 1 of the classes into the other class, is it illegal to import it by just using the class name and not the package name as well, ie
    if the package name is ie.tcd
    and the 2 class names are exp1.class and exp2.class, can I do this in class 2
    package ie.tcd;
    import exp1;
    public class exp2 {
    3. Is it illegal to import classes that are not explicitly part of any package or must a class be part of a package to be imported. I read somewhere that while this was always illegal it is only after jdk 1.4.2 that this is being enforced? If this is the case where in the Java Language specification is this actually written as I could not find it either?
    Thanks very much for any help,
    John

    Was just also wondering, 1 other thing, I am looking
    at someone elses code they have 2 classes (Class A
    and Class B) in the same package (pkg). The person
    imports class A into B:
    package pkg;
    import A;
    public class B {
    Is this legal code (or was it ever)?Not if A is really in pkg.A. If there is an A in the unnamed package it was legal, or at least it was understood by the compiler, and now it isn't (to both).
    Can you import or is there a point in importing a class in the same
    package?Only by naming the package in the import statement. If the current and the import statement are in the same package the import is redundant.
    If there is a point would you import just be
    using the class name (this would be illegal after jdk
    1.4) or should you use the whole package name even
    though it is in the package anyways?As I understand it you must always use the whole package name in imports.

  • Error during running a transpose package

    Hi Experts,
    We are facing an error while trying to run a transpose package. The package does not show the lines for selection of source and destination path and it gives an error when we try to click on the advance tab to see the parameters being passed in the package.
    Also the package is running correctly in one server but not the another one though both the servers have exactly the same environment.
    Please help us with your valuable advice.
    Thanks,
    Regards,
    Kamya Nagpal

    Try posting on the OA Framework forum.

  • Error while running data manager package

    Hi All,
    when i am running data manager package for currency conversion i am getting the following error
    "An exception with the type CX_SY_CREATE_DATA_ERROR occurred, but was neither handled locally, nor declared in a RAISING clause
    The data object could not be created: The type /B28/MHED7W9U does not exist."
    Plase suggest where i am making mistake.
    Thanks

    Below are our BPC versions:
    BPC on Server Manager: 5.0.486
    Data Manager from eData: 5.0.484
    BPC from eTool: 5.0.486
    Below is the total error message as per your suggestion to run Export package. (even with service account which we used to install the software we are getting same error message.)
    TOTAL STEPS  2
    1. Dump Data:     Failed  in 0 sec.
    [Selection]
    FILE=\ApShell_SK\FINANCE\DataManager\DataFiles\SKTEST.TXT
    TRANSFORMATION=\ApShell_SK\FINANCE\DataManager\TransformationFiles\System Files\Export.xls
    MEASURENAME=PERIODIC
    (Member Selection)
    Category: ACTUAL
    Time: 2006.JAN
    Entity:
    Account:
    DataSrc:
    IntCo:
    RptCurrency: 
    [Messages]
    An error occurred while executing a package.
    Package Error Events:
    ErrorCode = -1073668060
    Source = Dump Data
    SubComponent=
    Description = The task "Dump Data" cannot run on this edition of Integration Services. It requires a higher level edition.
    IDOfInterfaceWithError= {8BDFE889-E9D8-4D23-9739-DA807BCDC2AC}

  • Running multiple SSIS packages using SQL Server Agent question.

    I have a multitude of SSIS packages I want to run using SQL Server Agent.  What would the best practice be for running these jobs using SQL Server Agent?  One job per package or running all pakages from one job?  If you have an answer can
    you explain the technical reasoning behind your answer?  Thanks in advance.
    Stan Benner

    Hi, maybe a bit more analysis will give a better answer
    Do all the packages have to run in sequence? (if yes, single job better)
    Can the list of packages to be executed be grouped by dependency (ex package 1,2 and 5 must run in sequence and can be executed by one job, while package 3,4 are not dependent on package 1,2 and 5 can be run by a separate job).
    Can any jobs be run in parallel?
    How often will the package execution sequence change?
    How will you deploy your packages and job? (the more jobs to create the more install script needed and upgrade scenarios become messy).
    My personal preference:
    I create ONE ssis package which is executed by ONE sql agent job. lets call this 'PackageExecutionWrapper.dtsx'
    PackageExectionWrapper then contains multiple 'Execute Package' tasks for the packages you want to execute.
    In the package you can apply any package execution rules - which packages have to run after the other, which packages can run concurrently, which packages should only run if previous succeeded.
    If you need to change the sequence, simple, just update the PackageExecutionWrapper package.

Maybe you are looking for