URGENT: How to run a Java program from a different directory?

Hi.
How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
What would be the command to run the Java file from c:\Java.
I can't remember it and I need it asap.
Cheers.

If the class you are trying to run is MyApp.class, try
c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)".

Similar Messages

  • How to run the java program from another directory?

    Hi
    Assumption:
    data.java is in a package suncertify.db and place in a directory c:/code/suncertify/db/ directory
    data.class file: is in c:/code/suncertify/db/ directory
    current directory: c:/
    How can execute the data.class directly in c:/ directory without changing directory to c:/code/ ?
    Thanks in advance,
    Adrian

    Yes. You can use the -classpath and -sourcepath options to specify where to look for source files, and the -d option to specify where to generate the class files. Look up the usage of those options in the javac documentation:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html

  • How to run a java class from its package directory

    Hi,
    I hope someone can help me on the following ....
    Let say I have a Test.java class with the package definition: "package com.ams.eai.mq.fileAdapter;". I compiled the class into the directory c:\myJava\client\com\ams\eai\mq\fileAdapter. I have c:\myJava\client specified in my classPath and Path. Why is it when I go to the mentioned directory and enter at the prompt >java Test, I get java.lang.NoClassDefFoundError: test (wrong name: com/ams/eai/mq/fileAdapter/test).
    What directory am I supposed to be in to run my Test class ? Is there some other path that I need to specify but didn't ?
    Thanks for any help.

    You have to type out the fully qualified class name:
    java com.ams.eai.mq.fileAdapter.Test
    Even if you had the entire dir structure, "c:\myJava\client\com\ams\eai\mq\fileAdapter" in your classpath you'd still have to fully qualify the name of the "Test" class. What if there was another class named "Test" in a different package in your CP? The VM would have no way of knowing which "Test.class" you'd want to run.

  • How to invoke a Java Program from Oracle 10g?(uRGENT)

    Hello.
    I've a query, that i have a program, that basically retreives the records from the
    oracle table and then parser this information and then insert the values in corresponding database base tables. I want that, whenever the new program is inserted, a Trigger should fire and pass the most recently entered record to the Parser Program, means
    1) Firing a Trigge
    2)Storing the most latest data and pass it to the Parser PROGRAM
    Can someone tell me how to do this? How to invoke a Java Program from within the database? Please if anyone has examples provide me. Its very urgent and tell me what is the basic mechanism.
    Thankyou.
    Ben

    With Java Stored Procedures Java may be caleed from a database.
    http://www.oracle.com/technology/tech/java/jsp/index.html

  • Running a java program from a .asp page

    i'm looking for someone in the community that knows how to run a java program
    on a web server ( not an applet) from a asp page. The server as IIS 5 and the jre1.3.1
    any help or tips would be welcomed

    The following site explains in detail how you have to do it. I have done it and it works fine.
    If u still have problems, contact me at [email protected]
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q167941

  • How to run a Concurrent Program from the back end?

    Hi,
    How to run a Concurrent Program from the back end?
    Is it Possible to see that Concuurent Request id which we run from the back end, in the front end?
    If yes, then Please Give reply how to write the code
    Thanks in Advance,
    Bharathi.S

    This is documented in Chapter 20 of the Application Developers Guide http://download.oracle.com/docs/cd/B53825_03/current/acrobat/121devg.pdf. These MOS Docs also have some information available
    221542.1 - Sample Code for FND_SUBMIT and FND_REQUEST API's
    235359.1 - How to Launch Planning Data Pull MSCPDP using FND_REQUEST.SUBMIT_REQUEST
    HTH
    Srini

  • How to run a java program in command prompt

    hi i want to run a java program from in command prompt from another directory
    i want to run a file named First in C:\Program Files\Java\jdk1.6.0_07\bin
    so when i give the command
    java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    it doesnt works it shows
    C:\>java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Program Files\Java
    \jdk1/6/0_07\bin\First
    Caused by: java.lang.ClassNotFoundException: C:\Program Files\Java\jdk1.6.0_07\b
    in\First
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: C:\Program Files\Java\jdk1.6.0_07\bin\First. Pro
    gram will exit.

    but it prints
    C:\>java -cp "C:\Program Files\Java\jdk1.6.0_07\bin\" First
    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
    C:\>

  • How to run a java program in another folder

    Hello!
    I want to run for example the java class file in the path ./sourcecode/javafile.class. It works fine if I do the following:
    cd sourcecode
    java javafile
    but it cannot work if I do:
    java sourcecode/java
    The error it outputs is NoClassDefFoundError.
    Can someone tell me how to run a java program in another folder
    thanks a lot.

    You need to specify the classpath using the -cp flag when running. so instead of
    "java sourcecode/javafile"
    Try
    "java -cp sourcecode javafile"

  • How to run a java program via a batch file,which is called from a webserver

    REM This batch file runs the Spider with the [-v] option.
    REM Lines 51 through 54 are simple DOS commands..they call the Spider
    REM The location of the Spider package is the important piece of information here...
    REM a batch file has access to the whole computer where the server resides.
    setlocal
    set JDK=C:\j2sdk1.4.1_01
    set PATH=%JDK%\bin;.;%PATH%
    CLASSPATH=%JDK%\jre\lib\*.jar;.;%JDK%\jre\lib\ext\*.jar;.;%CLASSPATH%
    java spiderpackage.EntryPoint -v
    endlocal
    I am trying to call this batch file from my web server but I am unable to capture the result.I tried to append the result to a file but It writes nothing to it.What should I do to proceed?

    I am not entirely sure if this is analogous, but I once wrote a PHP script uner Linux that invokes java and returning the output. I found that it was necessary to pipe the output of the Java program from stderr to stdout in order to properly receive it in PHP. The command would be as follows:
    java spiderpackage.EntryPoint -v 2>&1
    The pipe syntax (2>&1) should be exactly the same under MSDOS. So add that, and then continue as normal (appending it to a file or whatever else you want to do). Hope that helps

  • How to run a java program in windows 2003 server from unix server.

    Hi ,
    I want to run a java program in windows 2003 server from unix machine ..
    will RMI helps me to obtain this.
    Please tell me the procedure to do this.
    Thanks in advance,

    rmi,web services,corba,web 2.0,xml,xls,dtd,rss,ruby on rails,https,soap,tags,blog,podcast,google

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • Running a java program from an icon

    I want to run my program from an icon on my desktop. I have a .bat file that I've built a shortcut to and it works.MY GUI program does display and run when I click on the icon. The problem is that the DOS window also shows up behind my GUI.
    Is there anyway to prevent the DOS window from showing? Or is there another way to run a Java program without resorting to a DOS command line or running it through FORTE or another IDD?

    Chris's solution worked well, with one small problem. Once my GUI starts, it takes up the whole screen. Normally when I run it, it appears as a small window.
    not a big problem, I can reduce it easily after it starts. But does anyone know a way to make it come up in the reduced size it norally comes up in when I run it from my IDE?

  • How to run a java program remotely

    hi,
    i have a simple hello-world java program on my windows machine.
    is it possible to run this program remotely from a linux server?
    any suggestions, links to suggestions will be helpful. thanks!

    i think that would be a problem for me, so i will need to use some other approach. what i'm trying to do actually is that we have a university server which is set up so that students can have combination fo shell and cgi scripts in their home directory and with that, they can have web pages.
    but students cannot use that server to run java applications. so to work around that, i was hoping that i can have my java application, and the database on my own windows machine, and be able to invoke the java program from the shell script on the linux server and once i have my ouptut, i can display that on the web page with CGI script.
    is there any other practical approach that i can use to accomplish the above?

  • How to execute a Java program from ODI

    Hi All,
    I am new to ODI. I would like to know whether its possible to execute a java program from ODI.
    Reason for this is, I would like to write information in error tables into a file. And after that another program will mail that error log to concerned person.
    Could anyone please help me with this?
    Thank you in advance
    Regards,
    Srini

    if you have the java code then u can create a procedure with Java BeanShell as the Technology and write your java code in the procedure

  • How to run a java prog from c prog

    hello all
    I wanted to run a java class from a c prog,
    can any body suggest the way in which this can be done, links or tutorials in this regard is highly appreciable,
    thanks in advance
    Message was edited by:
    mahima_vyas

    Let's say that the order of arguments is as below
    1. Jar file name
    2. Classpath
    Your shell script would look like this
    java -cp $CLASSPATH:$2 -jar $1 I am assuming that your jar file has the required main-class entry in its manifest. Note that $1...$9 represent the arguments to this shell script.
    The same goes for a batch file
    java -cp %CLASSPATH%;%2 -jar %1

Maybe you are looking for

  • Delay in save and open dialog boxes waiting for Sidebar "Favorites" section

    Upgraded Macbook Pro (3,1) from Snow Leopard 10.6.8 to Lion 10.7.2. Ever since upgrading, when opening or saving documents in any application, the Favorites section in the sidebar is blank for a few seconds, maybe 5-10, and then populates normally. I

  • Lightroom 5 glitching photos on import.

    I've been using Lightroom 5 for about a week without problems. Today I went to import two photo shoots and the images come in fine until LR does a second pass and then they are all glitched. I'm not doing anything differently with this import than I

  • Ipad home button not working after updating to iOS 4.3.3

    my ipad's home button was working fine until i updated the software to iOS 4.3.3. today. now it is completely unresponsive and it is rendering my ipad unusable.  is there any way to fix this problem?

  • Variable substitution using attribute

    hi, i want to use an attribute of an elemnet in variable substitution. i know how to use element in variable substitution and i know that i can use message header attributes in variable substitution, but if i create an element with an attribute how d

  • SPecify  card type error in SMW01

    Hi, We need to download customers from ECC to CRM , when executed , there is no error captured in SMQ2. But the BDocs are generated in  SMW01 and found  R1561 error with error u2018Specify a card typeu2019. Can anyone suggest what needs to be done to