Attention: Windows Users using JAVA 7 with MapTool b87

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Lee
Dragon
Posts: 958
Joined: Wed Oct 19, 2011 2:07 am

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Lee »

JamzTheMan wrote:What is the "Launcher" coded in? For personal reasons, I'd hate to see it hard coded (although I assume it would be coded into the cfg file at least)
It's coded in Java, taken from the code readily available on the MT repo. I just extended it to its current form. The obvious advantage of this is that it's cross-platform. I was able to use it on Linux, OS X, and Windows.
JamzTheMan wrote:But there shouldn't be a reason why it could just use a normal shell command to get the jar name based on * and then pass that name to the java shell command.
I just went and beat the issue by letting the user pick what MT jar to run, which, in turn, does get saved to the cfg file.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Azhrei »

As an update, b90 will have both of the scripts that appear in this thread (Launch MapTool.cmd and Launch MapTool.bat). Both will set the file.encoding property to UTF-8 as well. I've also put URL to the relevant forum posts in there as well, as a way of tracking where the scripts came from. (Some day I'll turn on post pruning in phpBB3 and then those URLs won't be any good, but I'm not worried about it for now. ;))

I'm including both but I think some documentation would be good. If these are known to work then I'll remove the individual batch files that currently exist now that have the memory sizes hard-coded.

Ideally, we'd have a single launcher (and Lee is working on that) but in the mean time it would be nice to have something flexible and reliable. I like Vhex's approach that checks the Java version, but I like Jamz's approach of reading the settings from a separate configuration file. (I know from experience that having users edit scripts is a recipe for disaster!)

Would you two care to get together and produce a single version? It might be easiest to add Jamz's reading of the config file to Vhex's code. (I'm just guessing based on what I saw. But I didn't pay that much attention to it.)

Thanks!

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by JamzTheMan »

Yea, Vhex's approach was definitely more comprehensive :) I'll let Vhex take first say at a merge otherwise I'll do it.

Az, I also used the same mt.cfg file that the launcher used. Upside if they use the launcher and change settings, it'll reflect in the bat file. Downside is the same. Not sure if this is good or bad, thoughts?
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Azhrei »

I'm not a windows guy, but I would think that's a good thing. It allows for the option of setting the values via a GUI but tweaking them "by hand" so to speak, if necessary.

User avatar
Vhex
Giant
Posts: 162
Joined: Fri Sep 09, 2011 4:41 am
Location: Honolulu, HI

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Vhex »

Started a new contract this week so I don't have a lot of time, but I took a quick look and did an update. This should merge Jamz's intent, if not the same code. I also added Azhrei's file encoding update to the command line call, but I'm not sure where to check to make sure it's working.

The only thing that should need to be changed before b90 are lines 49-51 (the Java version and download links). If Java 7 works, just change line 49 to =1.7 instead of =1.6 and then update the links to the right package. Right now it downloads jre-6u39, so if Java 6 is still needed then those links need to be updated to whichever update version MapTool is compatible with (u43 is the last version).

Also, I did some testing on this, but not as much as I would like so if anyone wants to put it through the paces feel free.

The code is below:

Code: Select all

@ECHO OFF
SETLOCAL

REM *******************************************************************
REM **        MapTool Launcher Script for Windows v2013-04-05        **
REM *******************************************************************
REM ** This MapTool launcher script checks the current version of    **
REM ** java to make sure that it matches what is needed for the      **
REM ** current version of MapTool.  It takes a single argument which **
REM ** can be the path to the version of Java that you want to use,  **
REM ** although this argument is not required.                       **
REM **                                                               **
REM ** If the path is not specified on the command line, the script  **
REM ** will check standard locations based on your system and try to **
REM ** find the correct version of java.                             **
REM **                                                               **
REM ** Original script in this thread:                               **
REM **        http://forums.rptools.net/viewtopic.php?f=3&t=21856    **
REM *******************************************************************

REM ===================================
REM === YOU MAY EDIT THESE SETTINGS ===
REM ===================================

REM **NOTE ON EDITING**
REM   The items below set the defaults for MapTool.  If a mt.cfg
REM   file is found (usually from having used the launcher) then
REM   those settings will override these settings.
REM   TLDR:  Set the variables in the mt.cfg file instead of here or delete the mt.cfg file.

REM Path to the JRE folder for the correct version of Maptool:
REM (Note that this is different from the mt.cfg file format, but still gets overwritten if mt.cfg exists)
SET MAPTOOL_JAVA_PATH=C:\Program Files\Java\jre6

REM Maptool memory settings (see docs for explanation)
REM Defaults are:
REM 		Max Memory: 1024
REM 		Min Memory: 64
REM 		Stacksize:  3
SET MAPTOOL_MAX_MEMORY=1024
SET MAPTOOL_MIN_MEMORY=64
SET MAPTOOL_STACKSIZE=3

REM =====================================
REM ==== DO NOT EDIT BELOW THIS LINE ====
REM =====================================

REM Set the compatible Java version
SET MAPTOOL_JAVA=1.6
SET MAPTOOL_JAVA_URL=http://javadl.sun.com/webapps/download/AutoDL?BundleId=73922
SET MAPTOOL_JAVA_URL_X64=http://javadl.sun.com/webapps/download/AutoDL?BundleId=73923

REM Debug mode is useful for seeing what is happening, normally FALSE
SET MAPTOOL_LAUNCHER_DEBUG=FALSE

REM Check to see if the mt.cfg file exists and use those variables instead of the ones in this script
:CheckMTcfg
SET FAILJUMP=CheckArgument
IF NOT EXIST "%~dp0mt.cfg" GOTO %FAILJUMP%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Reading variables from "%~dp0mt.cfg"
FOR /f "usebackq delims=^= tokens=1,2" %%a IN ("%~dp0mt.cfg") DO (
	IF /i %%a==MAXMEM SET MAPTOOL_MAX_MEMORY=%%b
	IF /i %%a==MINMEM SET MAPTOOL_MIN_MEMORY=%%b
	IF /i %%a==STACKSIZE SET MAPTOOL_STACKSIZE=%%b
	IF /i %%a==JVM SET MAPTOOL_JAVA_PATH=%%b
)
REM Remove quotes if there are any.
SET MAPTOOL_JAVA_PATH=%MAPTOOL_JAVA_PATH:"=%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Variables have been updated from mt.cfg they are as follows:
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:         MAPTOOL_MAX_MEMORY = %MAPTOOL_MAX_MEMORY%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:         MAPTOOL_MIN_MEMORY = %MAPTOOL_MIN_MEMORY%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:         MAPTOOL_STACKSIZE  = %MAPTOOL_STACKSIZE%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:         MAPTOOL_JAVA_PATH  = "%MAPTOOL_JAVA_PATH%"
REM The mt.cfg file will likely contain the full path to javaw.exe, but we need to check java.exe
REM to find the version, so we'll remove the path and tack back on the exes.
IF /i %MAPTOOL_JAVA_PATH:~-9%==javaw.exe (
	SET JAVA_PATH=%MAPTOOL_JAVA_PATH:~0,-9%java.exe
	SET JAVAW_PATH=%MAPTOOL_JAVA_PATH:~0,-9%javaw.exe
) ELSE (
	IF /i %MAPTOOL_JAVA_PATH:~-5%==javaw (
		SET JAVA_PATH=%MAPTOOL_JAVA_PATH:~0,-5%java.exe
		SET JAVAW_PATH=%MAPTOOL_JAVA_PATH:~0,-5%javaw.exe
	) ELSE (
		REM The name wasn't in a format we expected, so give up.
		SET JAVA_PATH=CouldNotParse
	)
)
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  After reading mt.cfg, the path to Java = "%JAVA_PATH%"
IF NOT EXIST "%JAVA_PATH%" GOTO %FAILJUMP%
GOTO CheckJava
 
REM Check to see if the needed version of Java was passed in calling the script
:CheckArgument
SET FAILJUMP=CheckHardcoded
IF NOT EXIST "%1" GOTO %FAILJUMP%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Checking path passed as argument -- %1
SET JAVA_PATH=%~1\bin\java.exe
SET JAVAW_PATH=%~1\bin\javaw.exe
IF NOT EXIST "%JAVA_PATH%" GOTO %FAILJUMP%
GOTO CheckJava

REM Check to see if the needed version of Java is specified in the SET command above
:CheckHardcoded
SET FAILJUMP=CheckPath
IF NOT EXIST "%MAPTOOL_JAVA_PATH%" GOTO %FAILJUMP%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Checking path in script settings -- %MAPTOOL_JAVA_PATH%
SET JAVA_PATH=%MAPTOOL_JAVA_PATH%\bin\java.exe
SET JAVAW_PATH=%MAPTOOL_JAVA_PATH%\bin\javaw.exe
IF NOT EXIST "%JAVA_PATH%" GOTO %FAILJUMP%
GOTO CheckJava

REM Check the version of Java that is in our path.
:CheckPath
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Checking Java version in path
SET JAVA_PATH=java
SET JAVAW_PATH=javaw
SET FAILJUMP=GetJava
GOTO CheckJava

:CheckJava
FOR /f "tokens=3" %%i IN ('"%JAVA_PATH%" -version 2^>^&1 ^| FINDSTR /i version') DO (
    SET JAVA_VERSION=%%i
)
SET JAVA_VERSION=%JAVA_VERSION:"=%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Java Version -- %JAVA_VERSION%

FOR /f "delims=. tokens=1-3" %%j IN ("%JAVA_VERSION%") DO (
    SET JAVA_MAJOR=%%j
    SET JAVA_MINOR=%%k
    SET JAVA_BUILD=%%l
)
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Java Version ^(Major^) -- %JAVA_MAJOR%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Java Version ^(Minor^) -- %JAVA_MINOR%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Java Version ^(Build^) -- %JAVA_BUILD%
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Checking to see if Java versions match:  %MAPTOOL_JAVA%==%JAVA_MAJOR%.%JAVA_MINOR%
IF %MAPTOOL_JAVA%==%JAVA_MAJOR%.%JAVA_MINOR% GOTO LaunchMapTool
GOTO %FAILJUMP%

:LaunchMapTool
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Launching Maptool
FOR %%m in ("%~dp0maptool-*.jar") DO SET MAPTOOL_JAR_FILE=%%m
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Executing command -- START "MapTool" "%JAVAW_PATH%" -Xms%MAPTOOL_MIN_MEMORY%M -Xmx%MAPTOOL_MAX_MEMORY%M -Xss%MAPTOOL_STACKSIZE%M -jar "%MAPTOOL_JAR_FILE%" -Dfile.encoding=UTF8 -DMAPTOOL_DATADIR="%CD%" run
START "MapTool" "%JAVAW_PATH%" -Xms%MAPTOOL_MIN_MEMORY%M -Xmx%MAPTOOL_MAX_MEMORY%M -Xss%MAPTOOL_STACKSIZE%M -jar "%MAPTOOL_JAR_FILE%" -Dfile.encoding=UTF8 -DMAPTOOL_DATADIR="%CD%" run
GOTO EndScript

:GetJava
ECHO You are currently running Java version %JAVA_MAJOR%.%JAVA_MINOR%, but MapTool requires Java
ECHO version %MAPTOOL_JAVA%.  If you already have the correct Java version installed
ECHO then you can tell the launcher in one of three ways:
ECHO     1.)  Edit your mt.cfg file and set the path there:
ECHO               Example:  JVM=C:\Program Files\Java\jre7\bin\javaw.exe
ECHO     2.)  Edit %0 and specify MAPTOOL_JAVA_PATH at the top.
ECHO               Example:  SET MAPTOOL_JAVA_PATH=C:\Program Files\Java\jre7
ECHO               **Note**  This only works if you do not have a mt.cfg file
ECHO     3.)  Run %0 with the path specified as an argument.
ECHO               Example:  %0 "C:\Program Files\Java\jre7"
ECHO.
ECHO If you do not have the correct version installed, this script can launch your
ECHO default internet browser to download it.
CHOICE /T 60 /C YN /D Y /M "Do you want to be taken to the download location for the correct version of Java"
IF ERRORLEVEL==2 GOTO EndScript
IF EXIST "%ProgramFiles(x86)%" (
	IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Launching URL for 64-bit -- %MAPTOOL_JAVA_URL_X64%
	START %MAPTOOL_JAVA_URL_X64%
) ELSE (
	IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE ECHO DEBUG:  Launching URL for 32-bit -- %MAPTOOL_JAVA_URL%
	START %MAPTOOL_JAVA_URL%
)

:EndScript
IF %MAPTOOL_LAUNCHER_DEBUG%==TRUE PAUSE
ENDLOCAL
And, in case the code does the weird thing it did earlier, here's the file (which I'll leave up for a few weeks): https://dl.dropbox.com/u/1172913/Launch%20MapTool.cmd

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Azhrei »

Awesome sauce! Thanks! I've put this into Launch MapTool.cmd and removed the batch files entirely. Hopefully this will work for everyone who tries it/needs it. And if not, we can always go back and retrieve the prior files.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by wolph42 »

Azhrei wrote:Awesome sauce!
wasn't if CIF around here who coined that phrase?

anyway, does this mean we can redownload the last build and have access to this?

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by aliasmask »

wolph42 wrote:
Azhrei wrote:Awesome sauce!
wasn't if CIF around here who coined that phrase?
That's an old late 80's, early 90's (for me) saying. I got it from a friend back then. Looking at MT history, it springs up here and there. I have no idea where is came from, but it was before what the Urban Dictionary says.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Azhrei »

wolph42 wrote:anyway, does this mean we can redownload the last build and have access to this?
Not yet. I don't want to do another "public" build, and simply updating the ZIP files in-place is a really bad idea from a version control standpoint. So it'll be in b90. If you want something current, visit SourceForge.net and browse the SVN trunk -- you'll get the most recent commits that way.

You can start here http://sf.net/projects/rptools/ and dig deeper: maptool -> trunk -> resource -> bin. (Here's the URL you'll end up at, but be warned: SourceForge is pushing out new software updates soon and URLs that point directly into the SVN repo are destined to change.)

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by JamzTheMan »

Awesome. I will test the new launch code this week on my pc's. I run off a network unc path so should be a good test for that.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
jfrazierjr
Deity
Posts: 5176
Joined: Tue Sep 11, 2007 7:31 pm

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by jfrazierjr »

Azhrei wrote:Awesome sauce! Thanks! I've put this into Launch MapTool.cmd and removed the batch files entirely. Hopefully this will work for everyone who tries it/needs it. And if not, we can always go back and retrieve the prior files.
Azhrei, I know we talked about this before, but can we please name these "shell scripts" WITHOUT the spaces. On every platform, calling from the command line the user has to do special quoting of some sort to get these to run.
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Azhrei »

jfrazierjr wrote:Azhrei, I know we talked about this before, but can we please name these "shell scripts" WITHOUT the spaces. On every platform, calling from the command line the user has to do special quoting of some sort to get these to run.
Ah, yes. Done and committed to SVN. :)

User avatar
Vhex
Giant
Posts: 162
Joined: Fri Sep 09, 2011 4:41 am
Location: Honolulu, HI

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Vhex »

You can just double click the script and the system will handle quoting for you. Otherwise you can use L (tab) from any command line to get it to do the quoting for you. Not that it's a big deal to call it Launch_MapTool.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by JamzTheMan »

Works great for me on Windows 8 and Windows 7 (both x64, all with Java 1.7) with changing line 49 to =1.7 launching both from local drive and UNC paths and launches latest version if multiple JAR's exist. Two thumbs up from me!


Although, I didn't have the java 1.7 links and test on a system with no java installed (or if there is java 1.6, does/should it prompt to download 1.7). As technically, the required java is just 1.6 or greater so should not force 1.7, but a prompt to ask the user once would be good.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Ditto
Giant
Posts: 179
Joined: Thu Jul 28, 2011 1:06 pm

Re: Attention: Windows Users using JAVA 7 with MapTool

Post by Ditto »

JamzTheMan wrote:Works great for me on Windows 8 and Windows 7 (both x64, all with Java 1.7) with changing line 49 to =1.7 launching both from local drive and UNC paths and launches latest version if multiple JAR's exist. Two thumbs up from me!


Although, I didn't have the java 1.7 links and test on a system with no java installed (or if there is java 1.6, does/should it prompt to download 1.7). As technically, the required java is just 1.6 or greater so should not force 1.7, but a prompt to ask the user once would be good.
Hey guys, sorry to jump in here, however, I'm just trying to figure out this whole Java 7 + maptools thing. Our group is eyeing the upgrade, and being the "techy" of the group, I'm trying to research :)

So, reading/scanning through this thread, b89 is *supposed* to be J7 compatible? Or should I be waiting for this b90 being worked on?

I did do some tests with b89, and J7 on Win7, but still encountering errors (and yes, I saw the smiley bug and tweaked it, still getting exceptions on keypress).

Thanks!

Post Reply

Return to “MapTool”