From: Kevin R. B. <kbu...@at...> - 2020-05-30 01:25:56
|
I struggled with getting DrJava to work. It was used in a course I was planning to take. I worked a lot time to figure out how to get DrJava to work, and I see that a number of other people over the years have had basically the same problem, and they don't always seem to get answers, so I figured blasting this information out on the mailing list might be helpful if it makes one more place people have a chance of finding something helpful. In my case, I am using a Linux system that has both OpenJDK and a manually installed Oracle JDK (extracted from a tarball obtained from java.com), along with some other JRE environments in various places. That said, I think basically the things I found might not necessarily entirely be platform-specific even if some of the details are, so I hope that even if a reader doesn't use Linux, if they read between the lines, so to speak, something worth trying might become evident. In any event, I "installed" DrJava by .jar file rather than by the installer (`DrJava Version : drjava-20190813-220051`). I ran it from the command-line `java -jar drjava-beta-20190813-220051.jar`. I then clicked `[ Manual Download ]` when it asked about installing updates (`drjava-beta-2019-220051`). DrJava reported that my compiler was `JDK 8.0_222`. Note, I don't know where that compiler came from. As far as I know, I didn't have that version installed. My OpenJDK was: $ /bin/java -version openjdk version "1.8.0_252" OpenJDK Runtime Environment (build 1.8.0_252-b09) OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode) I typed in a simple "Hello World" program, and every attempt to compile produced: Compiler Output: "Compilation completed." This is a bug, because in fact compilation apparently did not complete. Clicking `Run` produced: Interactions Welcome to DrJava. Working directory is /home/krb/Projects/Software/java Current document is out of sync with the Interactions Pane and should be recompiled! > Restarting DrJava, saving, clicking `Reset`, etc., would not clear the problem. In any event, at some point I noticed the Console tab was full of messages like: Console Compiler is using classPath = '[/home/krb/Projects/Software/java, /home/apps/drjava/drjava-beta-20190813-220051.jar]'; bootClassPath = 'null' Fatal Error: Unable to find package java.lang in classpath or bootclasspath At this point, I tried various things, but I focused on pointing DrJava to an Oracle Java JDK I had installed a few days ago. Everything I did was in `Edit | Preferences ... | Resource Locations`, though I beat around in there a while. All of the settings were "blank" before I started. Anyway, I eventually had some success after I'd set: Web Browser /usr/lib64/firefox/firefox Web Browser Command Tools.jar Location /home/raid/apps/oracle/jdk-1.8.0_251/jre/lib/tools.jar Display All Compiler Version [ ] Extra Classpath /home/raid/apps/oracle/jdk1.8.0_251/jre/lib /home/raid/apps/oracle/jdk1.8.0_251/lib > NOTE: Your PATHs will NOT be the same as mine! You need to use the > actual paths on your system. In my case I searched for "rt.jar" and > "tools.jar" that were obviously in folders related to an installed > JDK. At this point I decided to try to figure out the minimum required to get it working. After a lot of fiddling around, I found it is sufficient just to set `Preferences | Resource Locations | Tools.jar Location`, but ***with with one MAJOR caveat. You must BROWSE to the file using that dialog. YOU CANNOT JUST PASTE IN THE PATH!*** If you just paste in the path, it can look like it is set correctly, but the compiler will continue to not work. This was how I got the oracle jdk compiler to work. Next, I set about to see if I could get OpenJDK to work. I searched my entire system for another `tools.jar` that belonged to OpenJDK, and did not find one. Then I realized I did not have the DEVEL OpenJDK package installed (on Mageia Linux 7). java-1.8.0-openjdk-headless-1.8.0.252-1.b09.1.mga7 java-1.8.0-openjdk-1.8.0.252-1.b09.1.mga7 I installed: java-1.8.0-openjdk-devel-1.8.0.252-1.b09.1.mga7 Now, even after resetting defaults, DrJava no longer says it is using `JDK 8.0_222`, but rather `JDK 8.0-openjdk-1.8.0.252-1.b09.1.mga7.x86_64-OpenJDK`, and everything works fine with NO customization to preferences! I don't know where the heck `JDK 8.0_222` came from. There's nothing on my system with that version. I rather suppose it is some internal thing in DrJava. I think the takeaways are: * If DrJava says its using `JDK 8.0_222`, it probably is not going to work! * Make sure you actually have a `tools.jar` installed if your system might split up the OpenJDK installation. * Point `Tools.jar Location` to an existing `tools.jar` file where the JDK you are using is installed, and making sure to browse to it (not just paste in a path). |