Starting a java class through a bat file

J

Jerry Manner

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
 
J

Jerry Manner

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.

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
 
J

Jerry Manner

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.

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
 
J

Jerry Manner

Correction, you have told it to run *class* 'Java.RunAgent.src.runAgent'
instead of class 'runAgent.RunAgent'.

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
 
J

Jerry Manner

Correction, you have told it to run *class* 'Java.RunAgent.src.runAgent'
instead of class 'runAgent.RunAgent'.

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top