How Do You Troubleshoot “Error: Could Not Create the Java Virtual Machine”?

Problem scenario
You ran a Hadoop command but you receive this error:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

What do you do?

Solution
Run hadoop help. This error can happen when you have an incorrect flag.

 » Read more..

How Do You Install and Configure the rdf4j Server and Workbench GUI?

Problem scenario
You want to use the rdf4j (Resource Description Framework for Java). You want to install the rdf4j server and workbench. You are using Debian 9 Linux. What should you do?

Solution
Prerequisites
i. We recommend having a 30 GB of hard disk free.

ii. We recommend having 5.75 GB of RAM (it can be a combination of RAM and swap space).

 » Read more..

How Do You Find the Version of Java that is Installed on Your Windows Server?

Problem scenario
You want determine what version of Java is installed (if any). What do you do?

Solution
Open PowerShell and run this command:
(Get-WmiObject Win32_Product | Where {$_.Name -match “Java”}).Version

Alternative way without PowerShell:
1. Go to Control Panel -Uninstall a Program
2. See if Java is installed

 » Read more..

How Do You Troubleshoot the Java Program Message “java.sql.SQLException: No database selected”

Problem scenario
Your Java program returns this message: “java.sql.SQLException: No database selected”
What should you do?

Possible Solution #1
Your SQL statement was appropriate for a database but not for the circumstance of connecting to a SQL instance. Try show databases; instead of the SQL you were running.

Possible Solution #2
Did you connect to the SQL instance you thought you connected to?

 » Read more..

How Do You Run a Java Program to Run SQL Commands Against a MySQL Database?

Problem scenario
You have a MySQL database. Rather than use a SQL front-end application, you want to write a Java program that will run a SQL statement against the database. What should you do?

Solution

1. Install the Java compiler if it is not already installed. If you need assistance, see this posting.

2. Run this command:
curl -Lk https://www.javatpoint.com/src/jdbc/mysql-connector.jar /tmp/mysql-connector.jar

3.

 » Read more..

How Do You Install the Java Compiler on Debian or Ubuntu Linux?

Problem scenario
You are using Debian or Ubuntu Linux. You want to compile Java programs. What do you do?

Solution
Run these commands:
sudo apt-get -y update
sudo apt-get -y install default-jdk

 » Read more..

How Do You Troubleshoot the Java Program Message “com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database foobar”?

Problem scenario
Your Java program returns this message: “com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database foobar”

What should you do?

Possible solution #1
Are you using Amazon Aurora? AWS has a MySQL PaaS offering. You may have a section of the Java code that looks like this:

Connection con=DriverManager.getConnection(“jdbc:mysql://foobar-us-west-2b.abcdefghijk.us-west-2.rds.amazonaws.com:3306/foobar”)

Remove the last “foobar” from the end. The connection string should look like this for Aurora databases:

jdbc:mysql://foobar-us-west-2b.abcdefghijk.us-west-2.rds.amazonaws.com:3306/foobar

Recompile the program.

 » Read more..

How Do You Troubleshoot the Message “Error: Config file not found: /usr/lib/jvm/java-9-openjdk-amd64/conf/management/management.properties”?

Problem scenario
You are trying to run Apache Zookeeper or some other application. You enounter the problem Error: Config file not found: /usr/lib/jvm/java-9-openjdk-amd64/conf/management/management.properties. What should you do?

Possible solution
This is a workaround. Run these commands:
sudo mkdir -p /usr/lib/jvm/java-9-openjdk-amd64/conf/management/
sudo touch /usr/lib/jvm/java-9-openjdk-amd64/conf/management/management.properties

 » Read more..

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. If the .class file of the program you are running is in /home/jdoe/javaprograms run this command:

export CLASSPATH=/home/jdoe/javaprograms

2.

 » Read more..

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).

 » Read more..