title: Set default classpath to use in `java` command in command prompt
body: <p>What I'm trying to do is running a <code>.java</code> source by compiling and running it from command prompt (not using any IDE) using commands <code>javac</code> and <code>java</code> and the program connects with MySQL, so everytime I run the program from cmd, I need to specify path of the MySQL connector using <code>-classpath</code> switch of <code>java</code>. And entire command to run the program gets something like below:</p>
  
  <p><code>java -class .;path/to/connector/mysql-connector.jar MySQLConnect</code></p>
  
  <p>where I want it to be as simple as for other programs like <code>java MySQLConnect</code>
  and it should run the program.</p>
  
  <p>Is there any way I can add the connector's path to environment variables of Windows that <code>java</code> make use of it. I already tried by creating a new <code>CLASSPATH</code> variable in Windows environment variables and added absolute path of the connector with file name along, but that didn't worked.</p>
  
  <p>Please provide me the workaround of this Windows and Ubuntu as well.</p>
  
  <p>Thanks. </p>