Problem: Java/Jython Unable to Open File

Hello again, folks. It has been quite a while since I last posted on this forum. As I may have mentioned previously, for the fourth time since 1993, I recently resurrected my Hermes II BBS from several decades ago. Currently, I am in the process of writing a new game for my BBS, which is written in Python. While as a non-programmer I have made considerable progress with my Python module, at the moment, I am having one basic problem which neither I, nor ChatGPT, have figured out how to rectify, despite many hours working on it.

Basically, the Hermes II software that I use has its own Jython 2-based runtime environment. Within the file and folder structure of Hermes II, there is in fact a Jython folder, which among other things contains various packages, including a Hermes API package, a Jython package, a QT Java package, an MRJClasses package, as well as a few other things.

The python module I am creating is heavily based on the code of another BBS game which was quite popular within the BBS world quite a few years ago. That game is called Leech. Some of you older folks will no doubt be familiar with one flavor or another of this game.

At any rate, back around 2015 — or a little earlier — the last developer of my BBS software – Michael Alyn Miller – made a huge departure from the Pascal-based framework which was used to make games – meaning externals – for Hermes II, when he created a development system for externals – called External Development System – which is based on Jython, and not on Pascal. He then released a new version of Hermes II, which utilizes this then-new Jython framework.

The primary reason why he did this was to simplify the process of creating externals, so that SysOps who use his BBS software, can more easily create externals themselves for their own Hermes II BBSes, without all of the heavy coding and compilation work involved when using Pascal.

To show and teach SysOps how to create their own BBS externals with Python/Jython, he created an open source version of the Leech game, so that SysOps could learn from his code, which uses a lot of different functions and methods from the Jython development environment.

His Jython version of Leech in fact includes a number of class files, which after some online research, I figured out how to open with an app I found on the web. Upon opening these class files, I can see all of the imports he has made from, all of the strings he has made, function names he has created, etc.

For those of you here who may have experience with this stuff, you will probably find all of this very easy to understand. However, I am not a programmer of Pascal, Python, Jython, C or anything else. Thus, I have struggled since my journey began about a week ago, and a lot of it is still Greek to me.

But, trying my best to understand Michael’s coding examples, and more recently getting some help from ChatGPT — which is blowing my mind — I have made considerable progress for a 70-year-old n00b such as myself.

I now have the entry point for my game module set up in the file, which consists of six ANSI screens which serve as the welcome and backstory for my game.

I also have the framework for the main menu, which currently has 5 or 6 working menu commands. I haven’t even begun working on the real meat of the game yet.

This leads us to my current problem. In the storyline for my game, I am including an option on the main menu where the game’s users can go to a spiritual retreat to relax from work. It is a place for spiritual inspiration.

If the game user types in the key command for the retreat, they will be able to randomly display, as many times as they want, quotes taken from the Bible, which are all stored in a text file in the “strings” folder, which is inside of the “resources” folder. This text file contains over 3,000 verses and verse sets from the KJV Bible, which I have personally compiled since 2002.

The coding structure for all of this has already been added to the module, thanks to the Leech coding example, and to a lot of help from ChatGPT.

Now here is the problem — and I have seen through online research, that others have encountered this same problem too.

With all of this code in place, my game module is unable to load within my BBS environment, because the Java/Jython components are unable to open and read the text file which contains the aforementioned 3,000+ strings,.

The error output is stating the following. I have obfuscated the actual path for reasons of security:

Traceback (innermost last):
File “/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame/”, line 305, in ?
File “/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame//”, line 264, in main
File “/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame//”, line 96, in read_quotes

java.lang.SecurityException: java.lang.SecurityException: not allowed to read resources/strings/QuotesFile.txt

A runtimeException occurred.

So the problem is that I have absolutely no idea how to give — I assume — the permissions it needs to read the “QuotesFile.txt” file. It knows exactly where to find the file, and sees it, but it doesn’t have permission to open it, or Java doesn’t have permission, or Jython. I am really not sure which is trying to open the file. If someone can explain to me exactly how to do this – that is, provide the needed permissions – then hopefully, my game module will load again, and I will be able to continue working on it.

Please note that this is all happening in a Mac OS 9.2.2 environment, which is made possible by running the Qemu PPC emulator, which runs inside of macOS Sonoma 14.4.1, on my 2019 5K iMac.

So, if anyone knows the solution to this problem, and can explain it to me in layman’s terms, I would be most appreciative.

So there you have it.
Kind regards,

Bill Kochman

I don’t know a simple answer to that exact question, but I do have a suggestion for a hack that might help.

Given you are able to write and run code in, you could perhaps include the strings within the Python code itself (as “literal values”).

Something like:

quotes = ["Hello world this is quote 1", "This is quote 2"]

If the quotes are lengthy and include line feeds, this kind of style might help:

quotes = [
This string
spans several
As does this
second one""",

# Gives "As does this\nsecond one"

It might take a bit of fiddling to get the 3000+ strings into a suitable format like that, but many editors have features to help with this sort of thing… I can describe some of the tricks I use if that would help.

This might not be a suitable approach if the amount of RAM available to your code is limited (in this unusual environment), given the contents of the quotes variable is read into RAM, in full. So, if you go this way, I’d suggest setting up a test with a large amount of fake data (perhaps the same long string repeated 3000 times) and check that runs ok before spending time formatting the real strings.

1 Like

Hello Ashley. Thank you for the suggestion. However, I don’t think that is a feasible solution. It requires several functions and other stuff to even make this work, so it would require the retooling of some code. Having no background as a programmer, it has been a real struggle for me to even get this far, so I am really not inclined to mess with what already works.

Besides that, those 3,400 plus strings are NOT just single sentences. Some strings, although included on one line in the file, consist of multiple verses, so aside from having to retool the existing code, forcing the to load all of those strings into memory – which is about another 1.1 MB – would place a lot of extra strain on the BBS. So it is better for it to just pick one string at a time from the file, and display it to the user.

If you happen to know anyone who is heavily involved in Java, and particularly in Jython 2.7 and Python 2.7, and hopefully even Hermes II, they would be the kind of person who could answer my question. I do know one person who can definitely tell me how to fix this, but he has been radio silent with me for weeks now. Thus, I am stuck.

Did you check the permissions on the “quote” file as well as the folders it is within to see what permissions they have for “everyone”? Command-i click on the file and the folders.

Actually, this is all in Mac OS 9.2.2. While I did in fact check sharing permissions on all involved folders, I don’t believe that it has any bearing on what I am attempting to do, because from what I can tell, sharing in Mac Classic just concerns Internet sharing. It is not like setting folder and file permissions under macOS. As far as checking permissions on individual files, as far as I can tell, Mac OS 9.2.2 doesn’t even seem to allow that. It only allows setting permissions on folders, which you can then make recursive. But even with doing that, it still did not resolve the Java SecurityException I have been experiencing with trying to read the quotes file.