Ask Your Question

tani's profile - activity

2018-01-05 16:21:45 +0200 received badge  Good Answer (source)
2018-01-04 22:43:34 +0200 received badge  Nice Answer (source)
2017-12-26 22:15:12 +0200 received badge  Teacher (source)
2017-12-26 22:15:12 +0200 received badge  Necromancer (source)
2017-12-21 08:44:20 +0200 answered a question 'launched jmol viewer for Graphics3d Object' fails

I've got the identical situation occurring. What I've noticed is that if I open the sage shell and run jmol I get:

(sage-sh) tani@DESKTOP-HUU9IR5:~$ jmol
Error: Unable to access jarfile /opt/sagemath-8.1/local/share/jmol/Jmol.jar

However, if I go in to /opt/sagemath-8.1/local/share/jmol/ and run jmol it works:

(sage-sh) tani@DESKTOP-HUU9IR5:~$ cd /opt/sagemath-8.1/local/share/jmol/
(sage-sh) tani@DESKTOP-HUU9IR5:jmol$ ls
appletweb         COPYRIGHT.txt  Jmol.jar  JmolData.jar   LEAME.txt
build.README.txt  jmol           jmol.mac  JmolLib.jar    LICENSE.txt
CHANGES.txt       jmol.bat   JSpecView.jar  README.txt
(sage-sh) tani@DESKTOP-HUU9IR5:jmol$ jmol
history file is C:\Users\XXX\.jmol\history
user properties file is C:\Users\XXX\.jmol\properties
(C) 2015 Jmol Development
Jmol Version: 14.6.1_2016.07.11  2016-07-11 18:22
java.vendor: Java: Oracle Corporation
java.version: Java 1.8.0_151 Windows 10
Access: ALL
memory: 8.9/16.3
processors available: 8
useCommandThread: false
User macros dir: C:\Users\XXX\.jmol\macros
       exists: false
  isDirectory: false

I believe I understand part of what the underlying issue is. The java I have is a windows java that expects windows pathnames. I can make it work by editing the jmol shell script to run this:

java -Xmx512M -jar "c:\\program files\\sagemath 8.1\\runtime\\opt\\sagemath-8.1\\local\\share\\jmol\\Jmol.jar"

This will launch jmol from within sage, when you run things like

show(G,figsize=(5,5),title="Sample Figure",aspect_ratio=1);

So it seems like sage is expecting to run a java that works with these unix-like paths, but the java that is installed only accepts windows-like paths. In any case, launching jmol doesn't actually make the image display correctly. This is because the arguments that are passed contain another unix-like path, ie:


Once I modified that to have a windows-like path, I then opened that file and found that the file itself contained more unix-like paths. Once I modified that remaining path to a windows-like path, jmol did in fact render the image that I wanted.

So, this is obviously an awful solution, but what I've done is replaced the jmol bash script with a python script that takes all the parameters, modifies them to use windows paths, and runs java. It's dirty but it works.


import sys
import os
import re

scriptname = sys.argv[1]
original_scriptname = scriptname

scriptname = re.sub(r'/dot_sage/',r"c:\\\\users\\\\YOUR_USERNAME_HERE\\\\.sagemath-8.1\\\\",scriptname)
scriptname = re.sub(r'/',r"\\\\",scriptname)
zip = "" % scriptname

with open(original_scriptname,"w") as f:
   f.write("set defaultdirectory \"%s\"\n" % zip);
   f.write("script SCRIPT\n");

os.system("java -Xmx512m -jar \"c:\\program files\\sagemath 8.1\\runtime\\opt\\sagemath-8.1\\local\\share\\jmol\\Jmol.jar\" \"%s\"" % scriptname)