How Do You Troubleshoot this Error “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver”?

Problem scenario
In Linux you are trying to run a Java program that connects to a MySQL database. The program compiles, but it does not run. You get this error: “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver” What should you do?

Solution

1. Set the CLASSPATH variable in two steps. First set it to where the .class file is for the Java file you are running.

How Do You Get around The AccessDeniedException Error with SonarQube?

Problem scenario
You are trying to set up SonarQube for the first time. You run this command:

bash /opt/sonarqube/bin/linux-x86-64/sonar.sh console

You see this error:

“jvm 1 | java.nio.file.AccessDeniedException: /opt/sonarqube/temp/conf/es/elasticsearch.yml”

What do you do?

Solution
Make sure that the user who is running the command has the ability to execute files in the /opt/sonarqube/ directory (or wherever the destination is that you are installing Sonarqube).

How Do You Make an Environmental Variable Persist through a Reboot on a Linux server?

Problem scenario
Every time a server is rebooted, you have to manually set environment variables with the “export” command. You want a variable to persist through a reboot so you do not have to do this manual work. You want a variable to be in the environment of the OS every time you log in. You want the solution to be specific to one user but you want it to work for any distribution of Linux (a Debian or Red Hat derivative including SUSE,

How Do You Troubleshoot the Groovy Error “JAVA_HOME is not defined correctly”?

One of the following situations apply to you:

Problem scenario #1
You try to run a Groovy command (e.g., groovy foobar.groovy), but you get this error:
“groovy: JAVA_HOME is not defined correctly, can not execute: /usr/lib/jvm/java-9-openjdk/bin/java”

Problem scenario #2
You get this error when you run an “hdfs” command:

ERROR: /usr/bin//bin/java is not executable.

What should you do?

How Do You Troubleshoot the Ansible Playbook Error Associated with “[Errno 2] No such file or directory”?

Problem scenario
When running an Ansible playbook using the java_cert module you receive an message “[Errno 2] No such file or directory”. How do you fix this?
(If you were using a file linking step in the playbook and not the java_cert module, see this posting.)

Solution
Use the “executable” attribute of the java_certs module (https://docs.ansible.com/ansible/latest/modules/java_cert_module.html) to specify the full path of the keytool file.

How Do You Troubleshoot the Error “intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 … 1 ] “?

Problem scenario
You try to start Cassandra but you get this error:

“[0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:./bin/../logs/gc.log instead.
intx ThreadPriorityPolicy=42 is outside the allowed range [ 0 … 1 ]
Improperly specified VM option ‘ThreadPriorityPolicy=42’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.”

Possible solution #1
Migrate to Linux SUSE or a Red Hat family version of Linux (e.g.,

How Do You Create a Docker Image That Has Java 10 in It?

Problem scenario
You want to create Docker containers with Java 9.  How do you create a Docker image to make containers with Java 9 installed in them?

These directions were updated on 12/26/18.

Solution
Prerequisite

This assumes that you have Docker installed. If you need assistance with this, see these postings depending on your operating system:

Debian/Ubuntu
CentOS/Fedora/RHEL
SUSE

Procedures
1. 

How Do You Write a Java Program to Accept Text from the Command Terminal and Print It Back Out?

Problem scenario
You want to write a basic Java program to test it out.  How do you write a program to accept user input, specifically a alphanumeric input, and print it back to the screen?

Solution
1.  Install the Java Development Kit if you have not installed it yet.  If you are not sure you have it, run “javac -version“.  If it says that the command is not found,

How Do You Troubleshoot the Oracle and Java Message “java.sql.sqlexception ora-01003 no statement parsed”?

Problem scenario
You run a Java program that runs a SQL statement in an Oracle database.  You get this error: “java.sql.sqlexception ora-01003 no statement parsed”.  What do you do to fix this?

Solution
Run the Java program a second time.  Does the problem remain?  It could be that there was a successful DDL command, and this error could be ignorable.  

You may want to try these links for further info:
https://stackoverflow.com/questions/23866710/ora-01003-no-statement-parsed
https://community.oracle.com/thread/736289 (this link used to work)