Run class in jar file using command prompt

Hi,
I have created a jar file OSTBTLDataTransfer.jar using eclipse and tried to run a class Person in the package com.aqa.details using the command prompt like this
java -classpath com.aqa.details.Person
but this complained about a jar file dependency and i have set it to the classpath like this:
set CLASSPATH=C:\jarup\abc\ibatis-2.3.4.726.jar
but it couldn't find the dependency when i tried to run again.
please let me know your suggestions
Thanks,
KC

java -classpath OSTBTLDataTransfer.jar com.aqa.details.Person
or if you have an appropriate manifest in the jar simply
java -jar OSTBTLDataTransfer.jar

Similar Messages

  • Running a Program in JDeveloper using Command Prompt

    Hi,
    I downoladed Oracle JDeveloper 10g. I had written a simple java class called Echo. java. I want to run the file using command prompt. My JDK has the following path:
    F:\Sowmya
    My java file has the following path:
    F:\Sowmya\jdev\mywork\1\1\src\pkg1
    So, in order to compile the file, I gave the following command:
    F:\Sowmya\jdk\bin>javac F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo.java
    It worked and the Echo.class file was created.
    But, when I tried to run the file using the following command,
    F:\Sowmya\jdk\bin>java F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo
    Iam getting the following error:
    Exception in thread "main" java.lang.NOClassDefFoundError: F:\Sowmya\jdev\mywork\1\1\src\pkg1\Echo
    This didnt work either:
    F:\Sowmya\jdk\bin>java F:\Sowmya\jdev\mywork\1\1\classes\pkg1\Echo
    Iam getting the same error.
    Can any one please help me regarding this.
    Thank you,
    Sowmya.

    Yes, my class contains a main. It runs if I click run in JDeveloper. But, there is no output displayed. The following is the code:
    public class Echo {
    public static void main (String[] args) {
    for (String s: args) {
    System.out.println(s);
    }

  • Error While trying to Run load test  on OATS using Command prompt

    Getting the below error message while trying to execute command line to start OATS load test.
    log4j:WARN No appenders could be found for logger (oracle.oats.server.jndi.JndiL
    ookup).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
    fo.
    Error initializing controller connection to t3://rws21410019.us.oracle.com:8088/
    weblogic\n\n(message id=ctl.initError)
    oracle.oats.client.controller.ControllerException: Error initializing controller
    connection to t3://rws21410019.us.oracle.com:8088/weblogic\n\n(message id=ctl.i
    nitError)
            at oracle.oats.app.controller.client.ControllerClient.initController(Con
    trollerClient.java:268)
            at oracle.oats.app.controller.client.ControllerSyncedClient.<init>(Contr
    ollerSyncedClient.java:137)
            at oracle.oats.app.controller.client.OltCommandLine.<init>(OltCommandLin
    e.java:43)
            at oracle.oats.client.CommandLine.initController(CommandLine.java:748)
            at oracle.oats.client.CommandLine.run(CommandLine.java:179)
            at oracle.oats.client.CommandLine.main(CommandLine.java:61)
    Caused by: javax.naming.AuthenticationException [Root exception is java.lang.Sec
    urityException: User: weblogic, failed to be authenticated.]
            at weblogic.jndi.internal.ExceptionTranslator.toNamingException(Exceptio
    nTranslator.java:42)
            at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLIni
    tialContextFactoryDelegate.java:788)
            at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialCo
    ntextFactoryDelegate.java:682)
            at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialCon
    textFactoryDelegate.java:469)
            at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
    tialContextFactoryDelegate.java:376)
            at weblogic.jndi.Environment.getContext(Environment.java:315)
            at weblogic.jndi.Environment.getContext(Environment.java:285)
            at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCont
    extFactory.java:117)
            at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
            at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.init(Unknown Source)
            at javax.naming.InitialContext.<init>(Unknown Source)
            at oracle.oats.server.jndi.JndiLookup.createInitialContextInternal(Unkno
    wn Source)
            at oracle.oats.server.jndi.JndiLookup.createInitialContext(Unknown Sourc
    e)
            at oracle.oats.server.jndi.JndiLookup.createInitialContext(Unknown Sourc
    e)
            at oracle.oats.app.session.SessionClient.initSession(SessionClient.java:
    104)
            at oracle.oats.app.controller.client.ControllerClient.initController(Con
    trollerClient.java:262)
            ... 5 more
    Caused by: java.lang.SecurityException: User: weblogic, failed to be authenticat
    ed.
            at weblogic.common.internal.RMIBootServiceImpl.authenticate(RMIBootServi
    ceImpl.java:116)
            at weblogic.common.internal.RMIBootServiceImpl_WLSkel.invoke(Unknown Sou
    rce)
            at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
            at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
    dSubject.java:363)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
    146)
            at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:518)
            at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.jav
    a:118)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Please make sure the OLT server is running!
    Thanks

    This issue was resolved after changing the user name to "oats" this is the user name of weblogic server and not the OATS console.

  • How to convert .class into .jar file

    Hi,
    How to convert .class into .jar file

    jsf_VWP5.5.1 wrote:
    Hi,
    How to convert .class into .jar fileFrom a command prompt, cd to the location of your .class file(s).
    If you want to create a simple jar, use: jar -cf Whatever.jar Whatever.class
    If you want to compile all .class files in a directory into a jar, use *.class instead.
    Now, I'm going to assume you want to create an executable jar... here's how to do that:
    1) Create a blank text file; for this example, lets call it main.txt.
    2) In the first line of main.txt, type: Main-class: Whatever ('Whatever' should be the name of the class in your program where the main() method is located)
    3) Press enter to go to the next line (someone please correct me if I'm wrong, but if you don't insert the line break/CR after the Main-class: statement, this will not work... in my experience, this is true)
    4) Make sure you save this file in the same directory as your .class file(s).
    5) Type: jar -cmf Whatever.jar main.txt Whatever.class
    ...and that's about it. For more information on the usage of the jar command and to understand the switches (such as -cmf), try jar --help.
    Hope that helps.

  • How to create and use library JAR files with command-line tools?

    Development Tools -> General Questions:
    I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
    I have posted a simple example with one utility class, one console application class, and a Makefile:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
    Here is a console session:
    2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/hello/HelloConsole.java
    package com.example.hello;
    import static com.example.util.Hello.hello;
    public class HelloConsole {
        public static void main(String [] args) {
         hello("world!");
    2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -f hello
    find . -name '*.class' -delete
    javac src/com/example/util/Hello.java
    javac -cp src src/com/example/hello/HelloConsole.java
    echo "java -cp src com.example.hello.HelloConsole" > hello
    chmod +x hello
    2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
    $ ./hello
    hello, world!I believe I am looking for:
    1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
    2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
    3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
    I already know how t compile the utility class file.
    Any suggestions?
    TIA,
    David

    I finally figured it out:
    1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
    2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
    My key discovery was that if the code says
    import com.example.util.Hello;then the JAR must contain
    com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
    -classpath ext/com/example/util.jarThe code is here:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
    Here is a console session that demonstrates building and running the code two ways:
    1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
    2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
    (If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
    2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
    $ cat apps/com/example/hello/Console.java
    package com.example.hello;
    import com.example.util.Hello;
    public class Console {
        public static void main(String [] args) {
         Hello.hello("world!");
    2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
    $ cat libs/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -rf bin ext obj
    mkdir obj
    cd libs; javac -d ../obj com/example/util/Hello.java
    mkdir bin
    cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
    cd bin; java -cp .:../obj com.example.hello.Console
    hello, world!
    mkdir -p ext/com/example
    cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
    added manifest
    adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
    cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
    hello, world!
    2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
    $ tree -I CVS .
    |-- Makefile
    |-- apps
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.java
    |-- bin
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.class
    |-- ext
    |   `-- com
    |       `-- example
    |           `-- util.jar
    |-- libs
    |   `-- com
    |       `-- example
    |           `-- util
    |               `-- Hello.java
    `-- obj
        `-- com
            `-- example
                `-- util
                    `-- Hello.class
    19 directories, 6 filesHTH,
    David

  • How to compile & run using command prompt

    Hi all,
    I have a java application consisting of 3 packages & a jar file in the following hierarchy:
    -Project
    -classes
    -src
    -package1
    -package2
    -package3
    -file.jar
    The main class exists in package2 and uses classes within file.jar
    I want the steps to compile and execute the project using command prompt in windows such that the generated classes will be saved in the classes directory
    Can anyone help?
    Thanx in advance

    Hey,
    If your source(*.java) files are in src folder and ur currnet directory is project
    and you want all your class files to be classes folder then you can try this :
    c:\project>javac -cp src\file.jar -d classes\ src\*.javaAssuming that your file.jar file is in src folder.
    The above command will set the classpath to src\file.jar (-cp src\file.jar)
    -d classes\ - will generate all your class files with package hierarchy if any into classes directory.
    src\*.java - specifies the files to be compiled.
    Hope this helps.

  • How to use addKeyListener in a program running using command prompt

    Does anyone have any idea how to add the addKeyListener to a program running using command prompt.
    Let me explain how the program run.
    The program is start and accept call from other program. But from time to time, I need to issue some command by pressing the keyboard, let say, ESC is closed the program, F1 is showing the stated. F2.... (This is all need to run in the command prompt windows)
    My problem is this program does not have any gui interface, so how can it be added?
    i do it this way
    public void key(){          
    addKeyListener(this);
    But it have compile error.
    mainServerImpl.java:87: cannot resolve symbol
    symbol : method addKeyListener (mainServerImpl)
    location: class mainServerImpl
    addKeyListener(this);
    I did implement KeyListener. But just don't know how to solve this error.
    can anyone tell me how to solve it or point me a source that can help.
    Thank in advance!
    Regards,
    Tai Tan

    Write your own Thread, to do this:
    public class KeyThread extends Thread {
       public void run {
          while(true) {
             int i = System.in.read();
             if(i == 123) {
                break; // to stop the thread
    // in your main:
    Thread keyThread = new KeyThread();
    keyThread.start(); // calls run() of the thread

  • How to run test cases in a jar file using junit?

    Hi,
    I want to run test cases in a jar file using junit and the jar file is not in the class path. I wrote the following code, but it does not work.
    import java.net.URL;
    import java.net.URLClassLoader;
    import junit.framework.TestResult;
    import junit.textui.TestRunner;
    public class MyTestRunner {
         public static void main(String[] args) throws Exception{
              URL url = new URL("file:///d:/case.jar");
              URLClassLoader loader = new URLClassLoader(new URL[]{url});
              loader.loadClass("TestCase1");
              TestRunner runner = new TestRunner();
              TestResult result = runner.start(new String[]{"TestCase1"});
              System.out.println(result.toString());
    }Any ideas?
    Thanks a lot.

    Wouldn't it just be easier to put it on the classpath? You're trying to, anyway, with a URLClassLoader, albeit in an entirely unnecessarily complicated way

  • Create BPEL jar file using Bpelc via Java classes

    HI,
    I am trying to create the BPEL files ( xyz.bpel, bpel.xml, xyz.wsdl etc.. ) on the fly using Java code... Once I create all these files, I create a packaged jar (Ex : bpel_xyz_v2006_10_17__37256.jar) file and deploy the same in the Bpel PM.
    Right now, in order to create the jar file, I am running the bpelc.bat file under bpel/bin and then using the IBPELDomainHandle, I am deploying the process.
    But my requirement is to create the jar file using java rather than executing the bpelc.bat file..
    Can you please give me pointers as to how to achieve the same?
    Thanks
    Pramod

    Actually, I had figured out the part of calling the Bpelc class, but initially I was trying to create an object of the class and was not able to do so. That was where I got stuck.
    Eventually, I did something like the code snippet below and it works fine and the jar file is created. Just fyi for anyone looking in the future.
    String[] setupValues;
    setupValues = new String[]{ "-home", "D:\\product\\10.1.3.1\\OracleAS_1\\bpel", "-rev",
    "1.0", };
    Bpelc.main(setupValues);
    Thanks
    Pramod

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • Can i load a class in subdirectoy  inside a jar file using applet tag?

    hi every one.. thank you for reading ... i am really in dire need for the solution..
    my problem is that i have a jar file contianing a package which inturn contains my applet class...
    i am trying to access this applet class using a applet tag in html file. this html file is in same directory as the jar file. i am having no problems in windows but when i am doing this in linux apache server i was getting class not found exception. (already checked the file permissions). and when i am successful when using simple package directory instead of jar file . so gist of my quesition is "can i load a class in subdirectoy inside a jar file using applet tag in a html file"?

    When you tested in Windows were you using Internet Explorer? On Linux you will be using a different browser, usually Mozilla of some version, or Firefox. Note that the HTML tags for applets will be different between the browsers if you are using the object tag. Principally the classid value for the object tag will differ between Firefox and Internet Explorer.

  • How to run ODI scenario using command prompt

    Hi expets
    Please let me know if we can run ODI scenario using command prompt or any way other than operator.
    Regards
    Janakiram

    Go to <ODI_HOME>/oracledi/bin in command prompt and invoke startscen command with teh below parameters.
    Edited by: Guru Sankar on Feb 28, 2011 4:19 PM

  • How to bundle java help class into jar file ?

    Hi, all,
    I have some package in my project, with which I have a java help jar file as classpath, when I run my project, I need the jh.jar file in directory /jar/jh.jar.
    Now, I bundled all my class packages into a jar file, my.jar, together with the /jar directory. When i run my jar file with command:
    java -jar my.jar
    It tells me couldn't find javahelp class.
    What shall I do? How can I create my jar file with the jh.jar?
    Thanks in advance.

    I think you'd be better off just adding the jh.jar as
    a classpath argument and running it like that:
    java -classpath /myjavalibdir/jh.jar -jar myjar.jar
    ...otherwise you're stepping into redistribution of
    binary issues licensing-wise. That won't work either; when you run java with the -jar option, it ignores both the -classpath option and the CLASSPATH environment variable. However, it will see jh.jar automatically if you put it in the <path-to-java>/jre/lib/ext directory. But for distribution purposes, it might be simpler just to combime the contents of jh.jar into myjar.jar (if you use Ant, its <jar> task makes that very easy). Or, you can just run it this way:java -classpath myjar.jar;jar/jh.jar MyMainClassBTW, I don't think redistribution is a problem; otherwise how anyone even use JavaHelp?

  • Adding jar file in my gerareted jar file using netbean 4.0

    Hi,
    I write an application de process XML file using JDOM. I add the JDom package jar file to my project and everything work fine. But when I generate, my project jar file using netbean 4.0, my generated jar, is not working with the XML files anymore. Everything seems like it didn't include the JDOM jar file?
    Thanks for any help to fix the problem.

    I find that you can not use command-line such as java -classpath add classpath
    it can not work, I use netBeans4.0 i don't whether because of netbeans or java itself.
    you can add classpath in jar's Manifest.mf file
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
    Main-Class: chat.Main
    // add this line
    Class-Path: dir\*.jar //(jar file name)
    X-COMMENT: Main-Class will be added automatically by build

  • Can I increase heap memory without specify any class or jar file??

    Hi,
    I tried to increase my heap memory in this way :
    java -Xms256m -Xmx256m
    but I got an error ... it's seem that I must specify a class java or a .jar file ...
    This is the error :
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image
    can I increase heap memory without specify any class or jar file??
    thx

    chiara wrote:
    Hi,
    I tried to increase my heap memory in this way :
    java -Xms256m -Xmx256m
    but I got an error ... it's seem that I must specify a class java or a .jar file ...
    This is the error :
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    can I increase heap memory without specify any class or jar file??The job of java.exe is to execute java bytecode.
    What is it supposed to do with your request to use 256m of memory for heap
    when you are not giving it a class or a jar to run?

Maybe you are looking for

  • My iPhone 5 won't backup on iCloud

    I currently use an iPhone 5 but I've recently purchased an iPhone 6. I've been attempting to set up the iPhone 6, but my first issue was that the software on the 6 wasn't up to date, so I had to set up the phone as 'New' before I could proceed. Havin

  • Sound and no picture

    i'm running qt 7.2 in os10.4. up until recently all was fine. now when i click on something on the web that has a video, all i get is the sound and the control bar, no picture at all.

  • Bad quality playback from purchased songs

    Friends- I purchased an album from itunes. I played it from my iBook over airport to my stereo system. The quality was very poor. Any ideas? Thanks. -Robin

  • Final Cut Pro - Can the video move pre subframe?

    I recently have two videos. And I want want to synchronize these two videos. But I found that the video can only be moved pre frame and the sound of these two video cannot match perfectly.  So I detach the audio of the 2nd video and I try to synchron

  • ORG UNIT Hierarchy

    Hi All, I am working on a BI side of SAP. At my work place they have defined the ORG_UNIT Hierarchy in the poratl but not in the ECC Box. But there are reports our users are requesting to have a hierachial selection. Since it is not defined in ECC I