Running a java program via a batch file

I am unable to run a java program from a batch file that I created.
spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
echo ^<html^>^<body^>
echo hello^<br^>
call java spiderpackage.EntryPoint -v
echo ^</body^>^</html^>

This has nothing to do with java programming. Have a look at the windows help for the call command.
The echo <html> stuff doesn't make sense. What's it for?
The command in you batch file should be:
java -cp . spiderpackage.EntryPoint -v
assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory

Similar Messages

  • To run a java program via a batch file,when called from a web server

    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 run this batch file from my web server.I can see nothing on my browser.I can run the same program from my machine but unable to run from web server.what should I do?

    I am making my question more clear...
    I have a Windows batch (*.bat) file that echoes some html, then calls a java program the output of which is html as well, then echoes the final html.
    To make sure that the java program gets properly executed, I set the necessary environment variables (e.g., JDK, PATH, CLASSPATH, etc.). The script looks something like this:
    setlocal
    set JDK=path_to_JDK
    set PATH=path_to_java
    set CLASSPATH=path_to_java_classes
    echo ^<html^>^<body^>
    call java foo
    echo ^</body^>^</html^>
    endlocal
    The idea, of course, is to call this script through a browser, on a web server.
    Curiously, both echo lines return to the browser just fine, but any output from
    the java program (which just writes html to STDOUT) does not make it back.
    Can someone explain to me why this is happening? How do I set things up so that the output (STDOUT and STDERROR) from the java program make it back to the browser?

  • 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 using additional jar files

    Hi everyone in the forum,
    i ve created an app using the hFreeChart in eclipse, so i added them as external jar files and tested the program.
    now my problem is that the program should run using a terminal in win and i do not know how can i do to make the command line or the system to find them, i added to the path but i read somtehing about classpath, but i have no idea. if anyone can help?
    thanks in advanced

    Actually, the best way to prepare a program for regular running is to make it an executable jar file, which means adding a manifest file which contains (at least) a Main-class: and a Class-Path: line. Referenced class libraries typically sit in a lib directory next to the java file. Then you can run it using java -jar myprog.jar.
    Failing that create a batch file or link that supplied java with command line parameters including a -classpath=
    Using the class path environment results in too much contention between competing values of it.

  • Windows task scheduler to run batch file running a java program

    I have created a batch file that runs my SendEmail program. The batch file is in the same directory as the java program. The only line in the batch file is
    java SendEmail
    This works fine from the command prompt but from the windows task scheduler it fails to function. Any help on how I can overcome this problem will be greatly appreciated.
    THanks

    Looks okay. The classpath is set, too, I guess? Btw, try running javaw instead of java. I may err, but I think it can show a console, so you can watch any error messages.

  • Error while running Java program which call a file upload servlet

    Hi all,
    I have a java program which calls a servlet and sends the file to be uploaded by the servlet. I used Jbuilder to create java program and servlet program. I compiled both the programs and compilation suceeded and my class files are avaialbe in
    WEB-INF/classes/content directory. But now I am trying to run the Java program(this contains main method) from the command prompt, which should inturn call my servlet.(I have web.xml file inside WEB-INF dir). But I receive the following error
    C:\tomcat5.5.15\apache-tomcat-5.5.16\webapps\content\WEB-INF\classes\content>java MultiContentSender
    Exception in thread "main" java.lang.NoClassDefFoundError: MultiContentSender (w
    rong name: content/MultiContentSender)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    My dir strcture is as below
    TOMCAT_HOME/webapps/content/WEB-INF/classes/content/*.class
    I am not able to figure out the error, can anyone throw some light on this issue.

    You are trying to invoke the class from the command prompt. My guess is that MultiContentSender contains a package, which means that you'll need to add your WEB-INF\classes directory to the classpath before it will work. Classes stored in this directory are expected to be invoked through tomcat, which builds it's own classpath.

  • 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?

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

  • Running a java program in a directory other than the current directory

    How do I run a java program that's located in a directory other than the current directory?
    There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
    javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
    But when I try to run it with:
    java -classpath /dir1/subdir1 /dir1/subdir1/Test
    I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
    Any thoughts?

    You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test

  • Exception while Running a Java Program for UME.

    Hi Experts,
                           I am trying to run a java program to acess UME. Its a sample to create user but all of my samples are throwing this exception in NWDS  (Console).Can anyone tell me why is it throwing this exception .
    com.sap.security.api.UMRuntimeException: UME factory 'com.sap.security.api.IUserFactory' cannot be accessed because UME initialization has not started yet.
    Please check
            UMFactory.isInitialized() before using UME functionality.
        at com.sap.security.api.UMFactory.checkInitialized(UMFactory.java:1019)
        at com.sap.security.api.UMFactory.getUserFactory(UMFactory.java:801)
        at Search.main(Search.java:25)
    Exception in thread "main"
    Thanks in advance
    Somil

    Hi,
    Earlier i faced the same exception when i tried to call the UME form Standalone java application,To resolve this i used stateless session bean approach. i follow the Below Mentioned Steps,
    1:-- create an J2EE -- EJB module project.
    2:-- Create stateless session bean and define the require methods ,implement Local and remote interface methods  in your bean class.
    3:-- refer the UME apis in EJB Projects build path.
    4:-- Call UME in Bean class methods.Build the EJB project and Archive.
    5:--Now create an Enterprise application Project ,Include the EJB module project to your EA Project by right clicking on EA project.Build EA project and EAR file
    6:--Deploy the EAR file on your server.
    7:--Now from your standalone java application include these two projects in Project tab of your Application.
    8:--Lookup the stateless session bean in your java class by its default JNDI name ,Obtain remote or local Home interface,And execute the BEAN Method which deals with UME.
    You can also refer this tutorial in some parts of it UME apis(like IUser,UMFactory) are used in Servelets and EJB ,You can download this tutorial source from SDN for your reference.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/297f35cf-0201-0010-00b2-fe2f3e23d360
    Siddharth

  • How to set path to run a Java program?

    my pc os is win2000 service pack 3.
    cpu is celoron 667mhz
    256 pc133 sdram
    i have done the setting b4 run a java program but no any effect.
    setting as below:
    set path=c:\j2sdk1.4.1_01\bin
    set classpath=c:\j2sdk1.4.1_01\lib
    my java file is store in C:\Java, file name is HelloWorld.java, so when i type:
    C:\>
    C:\>Java\javac HelloWorld.java
    (the screen show me : java\javac not internal or external........")
    and i try again as follow:
    C:>
    C:>\Java>javac HelloWorld.java
    (the screen show : Exception in thread "main" java.lang.NoClassDefFoundError:HelloWorld/java)
    i cant do anymore, who can help me?

    you need to put the CLASSPATH to dir: c:\j2sdk1.4.1_01
    and also to the directory you are working
    For example, you are working in "C:\Myclasses". You need to put:
    set CLASSPATH = C:\j2sk1.4.1_01;C:\Myclasses;
    if you don't put your working directory, java doesn't find your classes
    Try it and luck!

  • 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)".

  • 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

  • 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:\>

  • I am not able to run the java Program

    Hi All,
    I am not able to run a java program... I am able to complie the program sucessfully when i am trying to run it i am getting a error:
    Exception  in thread "main" java.lang.NoClassFoundError : filename
    i have complie and run my programs frequently but now i am not able run my prevoius examples also ...
    Can u any body help me out...... I have also update the latest version of JRE but still my problem is not sloved.
    Thanks & Regards,
    Ravi

    Make sure you take package structure into account.
    If you have say
    package testing.things;
    public class Test
        public static void main(String[] args)
            System.out.println("World Hello");
    }in file Test.java, you compile it with (assuming your current working directory is at the folder in which the source file is located).
    javac -d . Test.javaand run it with
    java testing.things.TestThe -d . option creates the output at the current directory (with a folder structure matching your package structure).
    #

Maybe you are looking for

  • Error while calling Web Service from BPEL

    Hi, I am trying to call a web service from BPEL. I have successfully build the partner link and configured invoke activity. Now in Jdeveloper is not able to parse the request XSD and showing the following error in the Jdev Validating Process... Done

  • Setting up my "new" macbook

    I bought a new MacBook from the Apple Store for my daughter. The Mac rep patiently set up the computer for us. This week my husband bought what he thought was a"New" Macbook from another store. When I got home I found out that it was actually an open

  • Syncing my Ipod with my PC

    I also accidentaly deleted my itunes. However not finding out how to restore them, I added them back on manually. Not knowing what will happen, I have not tried to update my IPod with this new library (on my PC), as it has the original library before

  • Syndication of merged records to multiple backend systems (MDM 7.1)

    Hi all, I have setup an MDM scenario with >1 ECC systems connected to MDM via PI. Everything works fine in terms of end-to-end process from ECC to MDM or MDM to ECC (creation, update, syndication). I have also merged records in MDM from the same back

  • SYNC PHOTOS FROM BLACKBERRY TABLET TO LAPTOP

    Hi Everyone.. I installed the software that sync files from my tablet to laptop. When i connacted, it asked me to enter a password to use the software.. What password do I have to enter it?!  It asks for a device password? What is it? Sorry I'm only