Thursday, January 13, 2011

ODS graphics error

ERROR: Unable to load the Java Virtual Machine
Today I received this error while attempting to execute ODS graphics.  I was using SAS 9.2 on a windows XP platform.  In my prior life with another agency this problem has occurred when I upgraded from 9.1 to 9.2, so this must be a common issue.  Speaking with the local IT help desk and a SAS associate proved useless, yet the problem was solved.

The issue is an incorrect pathway present for your Java Virtual Machine.  You will need admin rights to fix this error, but once you access the files, it is quite easy.

1) Open the folder: C:\Program Files\SAS\SASFoundation\9.2\nls\en
  a) in this folder you will find a file called SASV9.CFG.
  b) make a copy of this folder called something else, i.e. SASv9_backup, just in case.

2) Open the program file containing your java files: C:\Program Files\Java

3) Open the file SASV9.CFG
   a) Scroll down until you hit the line that says:
        -JREOPTIONS=(-Dsas.jre.libjvm=C:\PROGRA~1\Java\JRE15~1.0_1\bin\client\jvm.dll
   b) This is the path SAS is taking to find your version of Java Virtual Machine.
   c) Return to the JAVA folder and check if that pathway exists, it probably won't.
   d) If you have the folder "JRE1.5.0_12" in the java folder then make a simple change to the pathway
   --JREOPTIONS=(-Dsas.jre.libjvm=C:\PROGRA~1\Java\jre15~1.0_1\bin\server\jvm.dll

 4) This is where I got hung up!
   a) Open SAS through the ORIGINAL pathway, not your normal shortcut.  The normal pathway is:
       C:\Program Files\SAS\SASFoundation\9.2\SAS.exe

5) Check to see if the fix worked by running:

%put JREoptions: %sysfunc(getoption(JREOPTIONS));
PROC JavaInfo;

If it runs the procedure with no errors, ODS graphics is ready to execute.


FIX 2.

For the second fix we will adjust the JREOPTIONS in the file SAS utilizes prior to going to the other SASv9.cfg we attempted to change.

1) Open C:\Program Files\SAS\SASFoundation\9.2

2) Locate SASV9.CFG, and make a back up

3) Open this file and under the first command line that states:

-CONFIG "C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG"

Add a second command line:

-JREOPTIONS=(-Dsas.jre.libjvm=C:\PROGRA~1\Java\JRE6\bin\client\jvm.dll -Djava.security.policy=!SASROOT\core\sasmisc\sas.policy -Dsas.ext.config=!SASROOT\core\sasmisc\sas.java.ext.config -Dsas.app.class.path=C:\PROGRA~1\SAS\SASVER~1\9.2\eclipse\plugins\tkjava.jar -DPFS_TEMPLATE=!SASROOT\core\sasmisc\qrpfstpt.xml -Djava.class.path=C:\PROGRA~1\SAS\SASVER~1\9.2\eclipse\plugins\SASLAU~1.JAR -Djava.system.class.loader=com.sas.app.AppClassLoader -Xmx128m -Xms128m -Djava.security.auth.login.config=!SASROOT\core\sasmisc\sas.login.config -Dtkj.app.launch.config=!SASROOT\picklist)

NOTE!  This whole code needs to be in one line.

This fix will work if in the JAVA folder you have the folder "JRE6". 

Run the check on SAS:

%put JREoptions: %sysfunc(getoption(JREOPTIONS));
PROC JavaInfo;

If this PROC runs without an error, ODS graphics is fixed.

 Why this works.

You will notice that the pathway SAS originally uses to identify Java Virtual Machine (Java\JRE15~1.0_1\bin\client\jvm.dll) doesn't exist.  SAS needs to find the program "jvm.dll" and so we must force SAS to find that program.  By fixing the pathway we allow SAS to locate the necessary program to run ODS Graphics, thus solving the problem.

This was a major pain today and just wish to share the fix.

11 comments:

  1. Thanks! The second fix worked for me.

    ReplyDelete
  2. Perfect, thanks a lot ! from South Korea :D

    ReplyDelete
  3. When I try to re-save the cfg file i get an access denied error. any suggestions?

    ReplyDelete
    Replies
    1. You need admin rights. You typically can't change any files in your program files if you don't have admin rights. Call your IT department to get temporary access. Else, if you are on your home computer, make sure you are logged in as the admin not a user. Hope that helps.

      Delete
    2. I am logged in as an admin but still no access

      Delete
  4. Good God I am so happy now after You helped me fix this problem! I used fix 2 as well, with the slight modification that it was in PROGRA~2 and that I had JRE7, plus, I found the CONFIG statement alone in a separate folder also called SASV.cfg.
    THANKS!

    ReplyDelete
  5. THANK YOU!!! I got a hint from "Why this works" part.

    ReplyDelete
  6. I tried both method...but after opening sas, a new error occurred which is ERROR: failed to attach to java during sas setup...
    Any advice?

    ReplyDelete
  7. We provide the best Java Training Courses in Chennai and we have the best trainers who are working on Top MNC companies with almost 10 years of experience in Java. With all the knowledge they have gained on job throughout the career is given as knowledge transfer to our students along with a lot of practical sessions.

    ReplyDelete