ianopolous / JPC

JPC - The fast x86 PC emulator in 100% pure Java
http://jpc.sourceforge.net
GNU General Public License v2.0
396 stars 64 forks source link

Exception in thread main error in Ubuntu 20.04 Focal Fossa. #8

Open SonicFan2020-best opened 2 years ago

SonicFan2020-best commented 2 years ago

I'm trying to make a program that uses your emulator to emulate Windows 95.

But on Ubuntu 20.04 Focal Fossa, I get this error message:

Exception in thread "main" java.lang.IllegalStateException at org.jpc.j2se.JPCApplication.getResources(JPCApplication.java:593) at org.jpc.j2se.JPCApplication.<init>(JPCApplication.java:205) at org.jpc.j2se.JPCApplication.main(JPCApplication.java:766)

How do I fix this?

ianopolous commented 2 years ago

The resources need to be in the class path. This includes for example the bios image.

SonicFan2020-best commented 2 years ago

The resources need to be in the class path. This includes for example the bios image.

wait you think i builded the emulator.

oh i should try that

SonicFan2020-best commented 2 years ago

alright lets try it

SonicFan2020-best commented 2 years ago

well didnt work :(

SonicFan2020-best commented 2 years ago

Nice. Even more errors. The errors

pengan1987 commented 2 years ago

It seems like current build of JPC is not working on JDK11 or later, if I run it with JDK1.8 it's running fine.

thurisaz-org commented 2 years ago

The problem is that Java 9 changed the class loader to no longer be a URLClassLoader A custom ClassLoader may need to be written to get it working on the current Java https://stackoverflow.com/questions/46694600/java-9-compatability-issue-with-classloader-getsystemclassloader

Edit: A Solution is pretty simple. Around like 523 to 525 should be replaced to the code below or whatever is more kosher

        /*if (!(cl instanceof URLClassLoader)) {
            throw new IllegalStateException();
        }*/
        URL[] urls = new URL[0];
        try {
            urls = Collections.list(cl.getResources("")).toArray(urls);
        } catch (IOException ex) {
            Logger.getLogger(JPCApplication.class.getName()).log(Level.SEVERE, null, ex);
        }