This is my run.bat file:
#echo off
start compactau.exe
"c:\program files\java\jre7\bin\java" -Xms512m -Xmx768m -cp jio.jar;log4j-1.2.9.jar;auagent.jar Auagent auagent.conf
Pause
When I run this file, I get the error the current directory is invalid. I uninstalled and reinstalled Java, then changed my Java location to c:\java\bin\java and adjusted my batch file like this:
#echo off
start compactau.exe
"c:\java\bin\java" -Xms512m -Xmx768m -cp jio.jar;log4j-1.2.9.jar;auagent.jar Auagent auagent.conf
Pause
But I still get the the current directory is invalid. How is this possible when I created the destination and folder name?
#echo off
start /D DBServerSimulator ./DBServerSimulator.exe
start /D DetectCheatServer ./DetectCheatServer/DetectCheatServerR
start /D ServerGuarder ./ServerGuarder/ServerGuarder.exe
start /D ManagerServer ManagerServer/ManagerServerR
start /D GateServer ./GateServer/Gate
start /D LocalSaveServer LocalSaveServer/LocalSaveServerR
start /D ShareMemProc ./ShareMemProc/ShareMemProcR
start /D GameServer ./GameServer/Line.exe
Start /D Auagent run.bat!
is my start.bat the last thing to start is my run.bat it starts the whole server boots up but because java wont kick in i get errors which i cant post coz it's image file only and i cant post them due to being a new user lol
you didn't specify a title to start. Use quotes for an empty title
start "" compactau.exe
Looks it is missing the directory where compactau.exe is stored.
Can you just add a line as
cd <path where the compactau.exe is stored>
e.g. cd c:\personal\exe_dir
before "start compactau.exe" so it can use the directory?
However the question is not clear enough in which line you get the error. Can you please mention it or post the error log?
and what are you going to do with Auagent auagent.conf, are they parameters to main method() ?
why don't you try by setting the path first before you run your java command?
You need not provide the whole absoulute path for using java command.
Related
I want to call ant from a batch file.
#echo off
cmd.exe /k cd /d E:\work\CRM
call ant
It's not working. Nothing is happening; neither showing any error nor nothing... How do I call ant?
I need to execute ant compile command from batch file from the current location E:\work\CRM.
Also I set the environment variables for ant:
ANT_HOME
JAVA_HOME
Get rid of cmd.exe /k since you're already in a batch file context
Add -d after ant to show debugging info
So, it might be a noob question but am still stuck with it. I have a batch command in a batch file as:
#echo off
start "" /D "C:\UpworkUP" upwork.exe --args -url=chrome://crash -disable-web-security -script-url=https://172.27.68.6/pre_alpha/
My doubt is how do I run this command from java itself without calling the batch file here. So per say, I do not want the batch file, I just need to run the command in it from java directly.
Making a batch file showing how arguments are being parsed.
#Echo %1
#Echo %2
#Echo %3
#Echo %4
#Echo %5
#Echo %6
#Echo %7
#Echo %8
#Echo %9
shows this result, how your arguments are being parsed most likely.
C:\Users\User>"C:\Users\User\Desktop\New Text Document.bat" --args -url=chrome://crash -disable-web-security -script-url=https://172.27.68.6/pre_alpha/
--args
-url
chrome://crash
-disable-web-security
-script-url
https://172.27.68.6/pre_alpha/
Which shows a errant space after crash. And maybe you neeed to escape = with a ^, so ^=. Fix first error, then see if you need to escape the equals.
Use:
Runtime.getRuntime().exec("YOUR_COMMAND");
About Runtime
cd /D "%~dp0"
#echo off
for %%f in ("Z:\java_projects\IDS\trunk\deployment\config\client\%1\Documentation\MappingEngine_*.xml")
do(
echo %%~nxf
java -jar EngineUtil.jar 192.67.64.172 %%f
)
Please tell me what I'm doing wrong.
I want to create a batch file to loop through a set files from a directory and run a jar file with one file at a time passed as argument.
The directory is dependent on a command line parameter.
I'm trying to set up a Minecraft Server and actually everything works fine. I'm starting the Server with a launch.bat file.
"%ProgramFiles%\Java\jre1.8.0_20\bin\java.exe" -Xmx2G -Xms1G -jar Tekkit.jar nogui
pause
And I have a second .bat file for backup purposes.
SET COUNTER=0
:loop
SET /a COUNTER=%COUNTER%+1
XCOPY "Server\*" "c:\Users\Benjamin\Desktop\Tekkit Server\backups\server_backup_%COUNTER%" /i /s
PING 1.1.1.1 -n 1 -w 600000 > NUL
goto loop
Now, all I'm trying to do is to start the two .bat files simultaneously, using only one .bat file.
I tried it with a third .bat file to start all:
start cmd /k CALL "C:\Users\Benjamin\Desktop\Tekkit Server\Server\launch.bat"
start cmd /k CALL "C:\Users\Benjamin\Desktop\Tekkit Server\backup.bat"
pause
It will actually start both .bat files, but suddenly, they start acting up and won't find their own files again:
C:\Users\Benjamin\Desktop>"C:\Program Files\Java\jre1.8.0_20\bin\java.exe" -Xmx2G -Xms1G -jar Tekkit.jar nogui
Error: Unable to access jarfile Tekkit.jar
C:\Users\Benjamin\Desktop>pause
Drücken Sie eine beliebige Taste . . .
C:\Users\Benjamin\Desktop>SET COUNTER=0
C:\Users\Benjamin\Desktop>SET /a COUNTER=0+1
C:\Users\Benjamin\Desktop>XCOPY "Server\*" "c:\Users\Benjamin\Desktop\Tekkit
Server\backups\server_backup_1" /i /s
File * not found
0 File(s) copied
C:\Users\Benjamin\Desktop>PING 1.1.1.1 -n 1 -w 600000 1>NUL
All three .bat files are in different directories.
Does anybody have a clue what I could do about my problem (besides stop being lazy, trying to reduce 2 clicks down to one ;) )
Thanks a lot
Benny
The problem is most likely your path directory. when you do cmd, cd to the "right" directory first, then run the bat file. for example:
cmd /k "cd /my/app/path && app.bat"
the && is the separator for multiple commands
I am starting a java programm under Red Hat Enterprise Linux Server release 5 (Tikanga).
directory structure:
- bin ->sc.jar,start-sc.sh,sc-lib-all.jar
- conf->log4j-sc.properties,sc.properties
command to run the java programm (which is perfectly working):
/usr/java/jdk1.6.0_37/bin/java -Xmx1024M -Dlog4j.configuration=file:../conf/log4j sc.properties -jar sc.jar -config ../conf/sc.properties
if i put it into a shell script the java programm can't find the prop file anymore.
shell script (start-sc.sh) looks like:
#!/bin/sh
/usr/java/jdk1.6.0_37/bin/java -Xmx1024M -Dlog4j.configuration=file:../conf/log4j-sc.properties -jar sc.jar -config ../conf/sc.properties
i am a newbie on shell scripting any ideas what i am missing? thx!
i guess you started your shell script not from the bin directory, which the dir start-sc.sh belongs to.
to explain it clear, let's make an example.
say, your script is here:
/foo/bar/bin/start-sc.sh
if you start it under /foo/bar/bin/, it (the relative path) should work.
but if you start your script from /home/yourHome/someDir/ , the relative path will point to $PWD/../, which is /home/yourHome/
you could either in your script first cd /foo/bar/bin/ before you start the java app. or do something like:
a=`dirname $0`
if [ $a = '.' ];then
a=`pwd`
fi
cd $a
/usr/java/jdkxxxx/java .....
It sound fine to me, does this version work?
#!/bin/sh
/usr/java/jdk1.6.0_37/bin/java -Xmx1024M -Dlog4j.configuration=file:$(pwd)/../conf/log4j-sc.properties -jar sc.jar -config $(pwd)/../conf/sc.properties
Edit #1:
Try put the following before launching your program:
echo `pwd`
The output tells you where you are running your script, so you can check if it's the right path or not.
Edit #2:
Try this script
#!/bin/bash
LOG4JCONF="/absolute/path/to/the/log4j/conf/file"
SCCONF="/absolute/path/to/the/other/conf/file"
/usr/java/jdk1.6.0_37/bin/java -Xmx1024M -Dlog4j.configuration=file:$LOG4JCONF -jar sc.jar -config $SCCONF