2

I have a STIGViewer-2.8.jar file. This works fine in Microsoft Windows 7 or 10, but does not work in Centos-7.6 linux. In linux when doing java STIGViewer-2.8.jar I get

Error.  Could not find or load main class StigViewer-2.8.jar

I have jdk-8u191-linux-x64.rpm installed, and this is Centos Server with GUI so I am in runlevel 5 with full graphics, everything else is working... Libreoffice, freecad, unameit. Is there some trick I need to do to get jar files to run in linux? Or is it a java thing and a problem with the jar file being Windows only?

7
  • java <classname> or java -jar <filename>. – Weijun Zhou Mar 19 '19 at 15:03
  • using java -jar StigViewer-2.8.jar produces the same error: could not find or load main class. – ron Mar 19 '19 at 15:13
  • I would also like to know why it works in Windows I can double click on a .jar file and it works, but in linux it does not; when double-clicking on .jar file from the windows explorer thing in linux I cannot use the folder/explorer thing it doesn't run via java instead it opens it like a container file. – ron Mar 19 '19 at 15:17
  • @ron Can you are confirm using Oracles and not the openjdk .RPM? – 0xSheepdog Mar 19 '19 at 15:18
  • I downloaded jdk-8u191-linux-x64.rpm from oracle and did a yum install on it. Then this jar file did not work. So using software gui i installed openjk 1.6, 1.7, 1.11; 1.8 already installed. – ron Mar 19 '19 at 15:25
1

I would like add that Red Hat has documented this issue for RHEL 7: DISA STIG viewer does not run with OpenJDK. This link needs a Red Hat login to work, so I will reproduce the key information here.

Environment: Red Hat Entreprise Linux 7 (RHEL7), OpenJDK 1.8

Issue: DISA STIGViewer does not run with OpenJDK:

$ java -jar ./STIGViewer-2.7.1.jar
Error: Could not find or load main class stigviewer.STIGViewer

Resolution: Use Oracle's JRE instead of OpenJDK for that application. Oracle's JRE or JDK has to be downloaded from Oracle's website.

Root Cause: OpenJDK cannot be used because the DISA STIGViewer application uses JavaFX internally which is not provided by OpenJDK.

Note that the default Java 8 binaries on RHEL 7/CentOS 7 come from the java-1.8.0-openjdk package.

The STIG Viewer 2.x User Guide also mentions this under Section 1.1 Notes:

This tool is produced in Java, and delivered as a single JAR file. It requires the Java Runtime Environment (JRE) be installed on the user’s machine to run (i.e., to run the STIG Viewer tool, Oracle Java is required). This allows the program to be run on any operating system for which the JRE is produced. This also limits the program to running at the permission level of the currently logged in user.

3

Having EPEL respository active, using software gui I removed all the OpenJava or OpenJDK stuff; did a search on java and unchecked using good judgement. Some things like json-glib or python-javapackages or tzdata-java I left alone.

then i did a yum install jdk-8u191-linux-x64.rpm which is from oracle.

That shows up in software gui as jdk1.8-2000:1.8.0.201-fcs with no Open wording, and all the OpenJava or OpenJDK stuff is not installed.

After that it works only using java -jar StigViewer.jar

If I do just java StigViewer.jar I still get the error, and if I double click on the .jar file from the windows explorer it opens the file like it was a container.

When installing centos 7.6; I chose Server with GUI and I think there was a choice for java stuff but if there was I know I didn't choose, so it seems centos installs openjava automatically to some extent.

update:

oracle jdk-8u201-linux-x64.rpm results in /usr/bin/java link to /etc/alternatives/java which then points to /usr/java/jdk1.8.0_201-amd64/jre/bin/java

it is THIS oracle java that works with this stigviewer.jar file only by java -jar stigviewer.jar

Other software like Octave and plplot rely on OpenJDK Headless Runtime Environment 8 which is java-1.8.0-openjdk-headless-1:1.8.0.201 and that results in the /usr/bin/java still linking to /etc/alternatives/java and that links to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64/jre/bin/java which is no workie for this stigviewer.jar file.

So I can remember to manually run Oracle's /usr/java/jdk1.8.0_201-amd64/jre/bin/java when I need to. It seems once OpenJDK is at all installed, the oracle rpm will not overwrite the links.

2
  • 3
    Your issues are also compounded by the $PATH and which java executable was being called. I downloaded and installed the jdk1.8-1.8.0_201 .RPM from Oracle; then I changed the /etc/alternatives link to point to /usr/java/latest/bin/java; finally, I executed /usr/java/latest/bin/java -jar ./path-to/STIGViewer-2.8.jar and successfully opened the app. Glad you worked it out! – 0xSheepdog Mar 19 '19 at 15:44
  • 4
    If you are using a JAR file you must use the -jar parameter before the name of the JAR file. That is in the man page for java and also mentioned in java -help command. – Mark Stewart Mar 19 '19 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.