Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Starting a java class through a bat file

Reply
Thread Tools

Starting a java class through a bat file

 
 
Jerry Manner
Guest
Posts: n/a
 
      06-21-2008
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
 
Reply With Quote
 
 
 
 
Jerry Manner
Guest
Posts: n/a
 
      06-21-2008
On 21 jun, 15:23, Lew <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Jerry Manner
Guest
Posts: n/a
 
      06-21-2008
On 21 jun, 15:23, Lew <(E-Mail Removed)> 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
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-21-2008
On Sat, 21 Jun 2008 01:18:22 -0700 (PDT), Jerry Manner
<(E-Mail Removed)> 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
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-21-2008
On Sat, 21 Jun 2008 07:38:15 -0700 (PDT), Jerry Manner
<(E-Mail Removed)> 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
 
Reply With Quote
 
Jerry Manner
Guest
Posts: n/a
 
      06-21-2008
On 21 jun, 17:16, Lew <(E-Mail Removed)> 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
 
Reply With Quote
 
Jerry Manner
Guest
Posts: n/a
 
      06-21-2008
On 21 jun, 17:16, Lew <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http: submit a form from a Java class through a .bat file Spendius Java 9 01-17-2011 07:45 AM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C++ 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C Programming 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui Python 0 04-27-2009 12:46 PM
adding assembly to windows\assembly through bat file Grant Merwitz ASP .Net 3 09-15-2005 11:40 AM



Advertisments