Page 1 of 1

Java and START in Batch

Posted: 04 Aug 2012 10:06
by YaYaBinks3
Hello all!
I'm trying to start a jar file using the java command, I'm planning on making an exe file that runs and runs a batch file that THEN runs a batch file thats inside the jarfile's folder.

Batch file 1:

Code: Select all

@echo off 
cls
START /B C:\Users\BillyV\AppData\Roaming\.techniclauncher\RunTekkit.bat
EXIT


Batch file 2:

Code: Select all

@ECHO OFF
java -Xmx1024M -Xms1024M -jar technic-launcher.jar
EXIT


It's extremely simple, but yet, it doesn't work. BF2 works when I double click it.
It throws

Code: Select all

Unable to access jarfile technic-launcher.jar
.
Why? And can anyone help?

Re: Java and START in Batch

Posted: 04 Aug 2012 12:36
by aGerman
BF2 inherits the working directory from BF1. Begin the 2nd BF with line

Code: Select all

@echo off &cd /d "%~dp0"

to change the working directory.

BTW: Forget about all EXIT commands and change your START line instead

Code: Select all

START "" /B cmd /c "%appdata%\.techniclauncher\RunTekkit.bat"


Regards
aGerman

Re: Java and START in Batch

Posted: 05 Aug 2012 01:59
by YaYaBinks3
Thanks. I'll try this when I have access to a computer.
I use my EXIT command because I'm going to use iexpress.exe and make an exe file to open batch file 1 (which is put in the temp file) to run batch file 2. Then I can pin the exe to my start menu and use it like that.

Re: Java and START in Batch

Posted: 05 Aug 2012 02:18
by YaYaBinks3
Thanks. It SORT of worked.
It comes up with all the Java help... why?

Re: Java and START in Batch

Posted: 05 Aug 2012 03:46
by foxidrive
The java command has a syntax error or the file cannot be found in the working directory.

That is usually when the help screen is displayed.

Re: Java and START in Batch

Posted: 05 Aug 2012 03:54
by YaYaBinks3
How do I fix it?

Code: Select all

@echo off &cd /d "%~dp0"
java -cp .;technic-launcher.jar
PAUSE


That's bat file 2

Re: Java and START in Batch

Posted: 05 Aug 2012 05:03
by foxidrive
YaYaBinks3 wrote:How do I fix it?

Code: Select all

java -cp .;technic-launcher.jar



That line looks wrong.

Re: Java and START in Batch

Posted: 05 Aug 2012 06:19
by YaYaBinks3
Then how do I fix that :|

Re: Java and START in Batch

Posted: 05 Aug 2012 07:26
by foxidrive
Read the help in the java.exe

Re: Java and START in Batch

Posted: 06 Aug 2012 01:12
by YaYaBinks3
Fixed.
Thanks you guys. Now I can make an exe which runs a bat (from a temp file) and then starts a java. The old exe broke! I can change the icon of the exe too :D