Starting a java class through a bat file

Discussion in 'Java' started by Jerry Manner, Jun 21, 2008.

  1. Jerry Manner

    Jerry Manner Guest

    Hi

    I have a bat file which I want to use to kick of a java class. The bat
    file looks like this:

    set domino=C:\runagent\NCSO.jar;c:\runagent\notes.jar;c:\runagent;.;c:
    \lotus\notes

    cd\

    java.exe -classpath %domino%;. Java.RunAgent.src.runAgent
    PAUSE

    Each time I try to run the bat file I receive this error message:

    C:\>java.exe -classpath C:\runagent\NCSO.jar;c:\runagent\notes.jar;
    ;c:\lotus\notes;. Java.RunAgent.src.runAgent
    Exception in thread "main" java.lang.NoClassDefFoundError: Java/Run
    Agent
    Caused by: java.lang.ClassNotFoundException: Java.RunAgent.src.runA
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Metho
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    The strange thing is that when I use Eclipse to run the same java
    class I don´t receive any error and the code of the class is running
    without any problem. So the problem must be the code in the bat file.
    Can someone tell me whats wrong with the bat file?

    Any help will be appreciated

    Regards
    Jerry Manner, Jun 21, 2008
    #1
    1. Advertising

  2. Jerry Manner

    Jerry Manner Guest

    On 21 jun, 15:23, Lew <> wrote:
    > ZZyZX wrote:
    > > Jerry Manner wrote:
    > >> Hi

    >
    > >> I have a bat file which I want to use to kick of a java class. The bat
    > >> file looks like this:

    >
    > >> set domino=C:\runagent\NCSO.jar;c:\runagent\notes.jar;c:\runagent;.;c:
    > >> \lotus\notes

    >
    > >> cd\

    >
    > >> java.exe -classpath %domino%;. Java.RunAgent.src.runAgent
    > >> PAUSE

    >
    > >> Each time I try to run the bat file I receive this error message:

    >
    > >> C:\>java.exe -classpath C:\runagent\NCSO.jar;c:\runagent\notes.jar;
    > >> ;c:\lotus\notes;. Java.RunAgent.src.runAgent
    > >> Exception in thread "main" java.lang.NoClassDefFoundError: Java/Run
    > >> Agent
    > >> Caused by: java.lang.ClassNotFoundException: Java.RunAgent.src.runA
    > >>         at java.net.URLClassLoader$1.run(Unknown Source)
    > >>         at java.security.AccessController.doPrivileged(Native Metho
    > >>         at java.net.URLClassLoader.findClass(Unknown Source)
    > >>         at java.lang.ClassLoader.loadClass(Unknown Source)
    > >>         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc
    > >>         at java.lang.ClassLoader.loadClass(Unknown Source)
    > >>         at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    >
    > >> The strange thing is that when I use Eclipse to run the same java
    > >> class I don´t receive any error and the code of the class is running
    > >> without any problem. So the problem must be the code in the bat file.
    > >> Can someone tell me whats wrong with the bat file?

    >
    > >> Any help will be appreciated

    >
    > >> Regards

    >
    > > Try adding the below package statement to your source file above the
    > > imports, if any.
    > > package Java.RunAgent.src;

    >
    > It is a trademark violation and *extremely* bad practice to name a top-level
    > package "Java" or any variant thereof.  DO NOT DO IT.
    >
    > "src" is a pretty bad package name, too, unless the purpose of code in the
    > package is to deal with matters related to "src".  Even then, it's weird.
    >
    > By convention, package names are spelled in all lower case.
    >
    > By what evidence do we conclude that the OP's code does not have a 'package'
    > declaration?  The OP has provided us no code.  They should, of course..
    >
    > We also don't know anything about the classes in the JARs, and what their
    > packages are.
    >
    > To the OP:  Get rid of "Java" as a part of your package name.  It's illegal
    > and harmful to maintenance.  Give us enough information to answer your
    > question, such as a short, self-contained compilable example
    > <http://sscce.org>
    >
    > The problem is in the part of your project that you did not show us.
    >
    > --
    > Lew- Tekst uit oorspronkelijk bericht niet weergeven -
    >
    > - Tekst uit oorspronkelijk bericht weergeven -


    HI

    Excuse me for not given the full info. The whole project was in my
    workspace folder. I just copied the project folder from their to the
    Java folder( i created this folder myself).
    In my project "Java" is not the package name. My package name is
    runAgent. The class name is RunAgent.

    Do you want the full project? How can I give you a self-contained
    compilable example?

    Regards
    Jerry Manner, Jun 21, 2008
    #2
    1. Advertising

  3. Jerry Manner

    Jerry Manner Guest

    On 21 jun, 15:23, Lew <> wrote:
    > ZZyZX wrote:
    > > Jerry Manner wrote:
    > >> Hi

    >
    > >> I have a bat file which I want to use to kick of a java class. The bat
    > >> file looks like this:

    >
    > >> set domino=C:\runagent\NCSO.jar;c:\runagent\notes.jar;c:\runagent;.;c:
    > >> \lotus\notes

    >
    > >> cd\

    >
    > >> java.exe -classpath %domino%;. Java.RunAgent.src.runAgent
    > >> PAUSE

    >
    > >> Each time I try to run the bat file I receive this error message:

    >
    > >> C:\>java.exe -classpath C:\runagent\NCSO.jar;c:\runagent\notes.jar;
    > >> ;c:\lotus\notes;. Java.RunAgent.src.runAgent
    > >> Exception in thread "main" java.lang.NoClassDefFoundError: Java/Run
    > >> Agent
    > >> Caused by: java.lang.ClassNotFoundException: Java.RunAgent.src.runA
    > >>         at java.net.URLClassLoader$1.run(Unknown Source)
    > >>         at java.security.AccessController.doPrivileged(Native Metho
    > >>         at java.net.URLClassLoader.findClass(Unknown Source)
    > >>         at java.lang.ClassLoader.loadClass(Unknown Source)
    > >>         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Sourc
    > >>         at java.lang.ClassLoader.loadClass(Unknown Source)
    > >>         at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    >
    > >> The strange thing is that when I use Eclipse to run the same java
    > >> class I don´t receive any error and the code of the class is running
    > >> without any problem. So the problem must be the code in the bat file.
    > >> Can someone tell me whats wrong with the bat file?

    >
    > >> Any help will be appreciated

    >
    > >> Regards

    >
    > > Try adding the below package statement to your source file above the
    > > imports, if any.
    > > package Java.RunAgent.src;

    >
    > It is a trademark violation and *extremely* bad practice to name a top-level
    > package "Java" or any variant thereof.  DO NOT DO IT.
    >
    > "src" is a pretty bad package name, too, unless the purpose of code in the
    > package is to deal with matters related to "src".  Even then, it's weird.
    >
    > By convention, package names are spelled in all lower case.
    >
    > By what evidence do we conclude that the OP's code does not have a 'package'
    > declaration?  The OP has provided us no code.  They should, of course..
    >
    > We also don't know anything about the classes in the JARs, and what their
    > packages are.
    >
    > To the OP:  Get rid of "Java" as a part of your package name.  It's illegal
    > and harmful to maintenance.  Give us enough information to answer your
    > question, such as a short, self-contained compilable example
    > <http://sscce.org>
    >
    > The problem is in the part of your project that you did not show us.
    >
    > --
    > Lew- Tekst uit oorspronkelijk bericht niet weergeven -
    >
    > - Tekst uit oorspronkelijk bericht weergeven -


    src is the folder name. I am using Eclipse 3.3.2 First I create
    a¨project( RunAgent). Eclipse automatically creates a src folder. Then
    I created the package ( runAgent) under this folder. In the package I
    then created the class (RunAgent).

    The java code runs correct in Eclipse but not through the batfile.

    Regards
    Jerry Manner, Jun 21, 2008
    #3
  4. Jerry Manner

    Roedy Green Guest

    On Sat, 21 Jun 2008 01:18:22 -0700 (PDT), Jerry Manner
    <> wrote, quoted or indirectly quoted someone
    who said :

    >I have a bat file which I want to use to kick of a java class. The bat
    >file looks like this:


    It is much simpler if you package your classes into a Jar. Then all
    you need do is

    myjar.jar

    and you are off flying, no classpath fuss.

    See http://mindprod.com/jgloss/association.html
    to set up the association between *.jar and java.exe

    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Jun 21, 2008
    #4
  5. Jerry Manner

    Roedy Green Guest

    On Sat, 21 Jun 2008 07:38:15 -0700 (PDT), Jerry Manner
    <> wrote, quoted or indirectly quoted someone
    who said :

    >My package name is
    >runAgent. The class name is RunAgent.


    see http://mindprod.com/jgloss/package.html
    on how to choose a globally unique package name.

    T
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Jun 21, 2008
    #5
  6. Jerry Manner

    Jerry Manner Guest

    On 21 jun, 17:16, Lew <> wrote:
    > Lew wrote:
    > > But you have told 'java' to expect package 'Java.RunAgent.src.runAgent'.

    >
    > Correction, you have told it to run *class* 'Java.RunAgent.src.runAgent'
    > instead of class 'runAgent.RunAgent'.
    >
    > > That is the error.

    >
    > --
    > Lew


    Hi

    I moved the class from the Java folder structure and placed it into
    another folder.
    I have chaged the bat file call to this:

    set domino=C:\runagent\NCSO.jar;c:\runagent\notes.jar;c:\runagent;.;c:
    \lotus\notes

    cd\

    java.exe -classpath %domino%;. lotus.domino.data.RunAgent
    PAUSE

    Now the code runs fine. It seems that I had my CLASSPATH and PATH
    variable wrong. They were not pointing to the right location.

    Thank you all for the time and help.

    Kind Regards
    Jerry Manner, Jun 22, 2008
    #6
  7. Jerry Manner

    Jerry Manner Guest

    On 21 jun, 17:16, Lew <> wrote:
    > Lew wrote:
    > > But you have told 'java' to expect package 'Java.RunAgent.src.runAgent'.

    >
    > Correction, you have told it to run *class* 'Java.RunAgent.src.runAgent'
    > instead of class 'runAgent.RunAgent'.
    >
    > > That is the error.

    >
    > --
    > Lew


    Hi

    I have chaged the bat file call to this:

    set domino=C:\runagent\NCSO.jar;c:\runagent\notes.jar;c:\runagent;.;c:
    \lotus\notes

    cd\

    java.exe -classpath %domino%;. lotus.domino.data.RunAgent
    PAUSE

    Now the code runs fine. It seems that I had my CLASSPATH and PATH
    variable wrong. They were not pointing to the right location.

    Thank you all for the time and help.

    Kind Regards
    Jerry Manner, Jun 22, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grant Merwitz
    Replies:
    3
    Views:
    9,003
    Grant Merwitz
    Sep 15, 2005
  2. chandan
    Replies:
    0
    Views:
    293
    chandan
    Mar 18, 2008
  3. ariel56
    Replies:
    0
    Views:
    838
    ariel56
    Oct 21, 2010
  4. Spendius
    Replies:
    9
    Views:
    1,004
    Spendius
    Jan 17, 2011
  5. Replies:
    2
    Views:
    357
    Dave Anderson
    Oct 10, 2006
Loading...

Share This Page