简体   繁体   中英

Call java class from bat file

I want to run a java class from a .bat file. I currently have the following in the .bat file:

@echo off
set path=%PATH%;C:\Program Files\Java\jdk1.7.0_60\bin
javac src\pt\logica\mne\job\TriggerLembrete.java
echo Successfully Compiled
pause

java src\pt\logica\mne\job\TriggerLembrete
pause

When I run this occurs many errors it says that some package no.

The .bat file is in ...\\AgendamentosOnline and the class I want to run in ..\\AgendamentosOnline\\src\\pt\\logica\\mne\\job

This class uses some jar that are in ...\\AgendamentosOnline\\WebContent\\WEB-INF\\lib

I think the error has to do with the fact that he did not know where the jar. How do I define this in the .bat file?

Thanks in advance.

If you know correctly which jar is referenced by class(I repeat if you exactly know) then you can do something like this

java -cp \WebContent\WEB-INF\lib\jarName.jar mainClassToBeRun

hope this helps!

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM