Known Issues and Workarounds/Fix for Java 7 with Linux 64

From Towns Wiki
Jump to: navigation, search

The following is a script that may be included in versions beyond 0.39.2 and was created to deal with Java 7 on Linux 64, and a keyboard issue. Only use it if you know what you're doing.

 #!/bin/sh
 elferror=".elferror.txt"
 liberror="liblwjgl.so: wrong ELF class: ELFCLASS32"
 lwjgl_download="http://downloads.sourceforge.net/project/java-game-lib/Official%20Releases/LWJGL%202.8.2/lwjgl-2.8.2.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjava-game-lib%2Ffiles%2FOfficial%2520Releases%2FLWJGL%25202.8.2%2Flwjgl-2.8.2.zip%2Fdownload%3Fuse_mirror%3Dswitch&ts=1326216183&use_mirror=dfn"
 #FIX for some VM's other then METACITY
 #save old value before unsetting
 oldXMODIFIERS=$XMOFIFIERS
 unset XMODIFIERS
 java -Djava.library.path=lib/native/ -Xms512M -Xmx512M -jar lib/xaos.jar 2> $elferror
 #Is the exit code not 0, and does our file contain the ELF class error?
 if [ "$?" -ne 0 ]; then
   is_this_ELFERROR=$(cat $elferror | grep "$liberror" | wc -l)
   if [ $is_this_ELFERROR -eq 1 ]; then
      if [ -d oldlib ]; then
         echo "Hi, sorry to bug you, but it still seems things dont work, despite trying my best."
         echo "I will restore your old lib directory now so you can try yourself."
         rm -rf lib
         mv oldlib lib
         echo "Done, good luck. Try checking our forums at http://www.townsgame.com/forums"
         echo "Hit enter to close this window."
         read a
         exit 1
      else
         echo "Hi,"
         echo "It appears you are trying to run Towns with Java 1.7 on 64 bit Linux."
         echo "Sadly, this does not work because of some lwjgl issues."
         echo ""
         echo "If you have an active internet connection I can try fix this for you."
         echo "Do you want me to try? (Y/N) [N]"
         read yesno
         if [ "$yesno" = "Y" ]; then
            echo "Ok trying to download the right libraries, one minute."
            if [ -f "lwjgl*.zip" ]; then
               rm lwjgl*.zip
            fi
             wget $lwjgl_download -O lwjgl.java1.7.zip 2> /dev/null
            if [ $? -eq 0 ]; then
               echo "Moving old lib dir to oldlib"
               mv lib oldlib
               echo "Making new lib directory"
               mkdir lib
               echo "Copying stuff we need from oldlib to lib"
               cp oldlib/xaos.jar lib/
               cp oldlib/slick-util.jar lib/
               echo "Extracting the files we need from the new lwjgl"
               unzip -j lwjgl.java1.7.zip lwjgl-2.8.2/jar/lwjgl.jar -d lib/
               unzip -j lwjgl.java1.7.zip lwjgl-2.8.2/jar/lwjgl_util.jar -d lib/
               unzip -j lwjgl.java1.7.zip lwjgl-2.8.2/native/linux/* -d lib/native/
               rm lwjgl.java1.7.zip
               echo ""
               echo "ok try again! Hit any key to close this window and then start the game again!"
               read a
            else
               echo "I am sorry, but downloading the correct files did not seem to work."   
               echo "Please see http://www.townsgame.com/forums/viewtopic.php?f=8&t=450 for more information"
               echo "on running Towns with Java 1.7 64bit or use Java 1.6"
               echo ""
               echo "Hit any key to close this window"
               read a
            fi
         else
            echo "Ok, doing nothing."
            echo "Hit any key to close this window."
            read a
         fi
      fi
   else
      #not elf error, ok lets print it and hope they can use this info then.
      echo "not an elf error"
      result=$(cat $elferror)
      echo $result
   fi
 fi
 #If there were XMODIFIERS, set them again
 if  [ ${#oldXMODIFIERS} -ge 1 ]; then
   echo "Setting XMODIFIERS to old value."
   export XMODIFIERS=$oldXMODIFIERS
 fi
 #remove the output file that might contain an the ELF error from lwjgl
 if [ -f $elferror ]; then
   rm $elferror
 fi