Java-database connection Java-MySQL connection ③-1: How to set CLASSPATH in environment variable / September 2017

CLASSPATH setting

Parts (jar files) that are not included in the standard system library are called "external libraries". The JDBC driver is one of the external libraries. In order to use an external library in addition to the standard system library, it is necessary to make settings to tell the compiler and JVM (JavaVirtualMachine: Java virtual environment) the location of this external library. This setting is called "CLASSPATH setting".

There are several ways to set the CLASSPATH, In this Qiita personal memo,

  1. How to set CLASSPATH to environment variable
  2. How to set CLASSPATH to the build bus of Eclipse (Pleiades All in One) Will be described.

How to set CLASSPATH to environment variable

Copy mysql-connector-java-x.x.xx-bin.jar Open Windows Explorer (Windows button + E button) Open C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib

Paste the mysql-connector-java-x.x.xx-bin.jar you copied earlier After pasting, you can close Windows Explorer

Then click the Windows button-> right-click on your computer-> select Properties Click the advanced system settings link Press the environment variable button

If CLASSPATH does not exist

If the variable CLASSPATH does not exist in the "System environment variables" list, register as follows.

Press the new button under "System Variables". Variable name: CLASSPATH Variable value:.; C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib \ mysql-connector-java-x.x.xx-bin.jar;

If CLASSPATH exists

If the variable CLASSPATH exists in the "System environment variables" list, register it as follows.

Select the column where the CLASSPATH is displayed Press the edit button under "System Variables"

Variable name: CLASSPATH Variable value:.; Xxxxxxxxxxxxx.jar; C: \ ProgramFiles \ Java \ jdkx.x.x_xxx \ lib \ mysql-connector-java-x.x.xx-bin.jar; Add in the format.

If this doesn't work, set it from Eclipse of your memo next time (low voice)


☆ Variable value:.; C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib \ mysql-connector-java-x.x.xx-bin.jar; Variable values are declared separated by a; (semicolon) symbol.

The first. (Dot) means the Java program (the program you are about to create) that connects to the JDBC driver. Also, C: \ Program Files \ Java \ jdk x.x.x_xxx \ lib \ mysql-connector-java-x.x.xx-bin.jar shows the filename and location of the external library that will be the JDBC driver.

If you write an instruction to call the JDBC driver manager in the Java program created after this, the JDBC driver will call the specified JDBC driver further and try to connect to the target database.



Java-database connection / Java-MySQL connection ① Overview of JDBC and JDBC driver (2) JDBC driver acquisition method (for MySQL) and data connection preparation ③-1 How to set CLASSPATH in environment variable ③-2 How to set CLASSPATH to Eclipse build busLoad JDBC driverConnect to database (MySQL) to search table information and display search results


Recommended Posts

Java-database connection Java-MySQL connection ③-1: How to set CLASSPATH in environment variable / September 2017
Java-database connection Java-MySQL connection ③-2: How to set CLASSPATH to the build bus of Eclipse (Pleiades All in One) / September 2017
How to set Lombok in Eclipse
How to reflect seeds.rb in production environment
Java-database connection Java-MySQL connection ④: JDBC driver loading / September 2017
How to use environment variables in RubyOnRails
How to install Titan2D (v4.2.0) in virtual environment
How to add a classpath in Spring Boot
[Java] (for MacOS) How to set the classpath
Java-database connection Java-MySQL connection ①: JDBC and JDBC driver overview / September 2017
[Rails] How to use PostgreSQL in Vagrant environment
How to set environment variables in the properties file of Spring boot application
How to create a Java environment in just 3 seconds
[Rails 6] How to set a background image in Rails [CSS]
Java-database connection Java-MySQL connection ⑤: Connect to the database (MySQL) to search table information and display search results / September 2017
How to set chrony when the time shifts in CentOS7
How to set character code and line feed code in Eclipse
What happened in "Java 8 to Java 11" and how to build an environment
How to set and describe environment variables using Rails zsh
[Docker context] ~ How to access docker in remote environment from VScode ~
How to set up a proxy with authentication in Feign
How to set Docker nginx
How to set Java constants
[Rails] How to execute "rails db: create" etc. in production environment EC2
How to set and use profile in annotation-based Configuration in Spring framework
How to install the language used in Ubuntu and how to build the environment
How to store the information entered in textarea in a variable in the method
[Rails] How to reset the database in production environment (Capistrano version)
How to use Lombok in Spring
How to run JUnit in Eclipse
How to iterate infinitely in Ruby
[Rails] How to write in Japanese
How to run Ant in Gradle
How to master programming in 3 months
How to set Spring Boot + PostgreSQL
How to learn JAVA in 7 days
How to get parameters in Spark
How to install Bootstrap in Ruby
How to use InjectorHolder in OpenAM
How to write Java variable declaration
How to introduce jQuery in Rails 6
How to use classes in Java?
How to name variables in Java
How to concatenate strings in java
How to install Swiper in Rails
How to develop from VScode in a remote destination environment or a remote destination container environment
How to execute with commands of normal development language in Docker development environment
How to change the value of a variable at a breakpoint in intelliJ
How to migrate a web application created in a local docker environment to AWS
[Swift] How to set an image in the background without using UIImageView.