Where is 1.Java Build path
Under the properties of the right mouse button of the project, or in the Java of Window's properties
2. There are two options for project and folder
Project: In Projects
Folder: In folders, there are two places to fill in
SOURCE folder name: Build directory to search SRC
Default output folder or output folder name: Compiled output directory bin
Build path for 3.java
Search under SRC, the folder under SRC is the default package, and after compiling, a new bin directory is created under the project, and all the compiled files under SRC are compiled automatically.
4.maven file format
SOURCE folder name: Build the search Directory
Default output folder or output folder name: Compiled output directory jdbctest/target/classes, does not compile automatically, only in compile will compile.
So before the compilation and clean after an exception, error: The main class could not be found or could not be loaded (as long as the class is used, the new method will be automatically compiled and loaded), so running the file requires compiling first
Issue 1: Error: The main class could not be found or could not be loaded
The above has been explained
Problem 2.src/main/java based on Maven's build, using compile will compile the. java file in the directory, put it under target, and for other files will not be added to Java/main/resource, will only be merged, not compiled , if it is a Java file, the merge is in Target or Java file, similar to test.
5. For a number of reasons, the result is as follows
public class Drivermanagertest {//file is built on compile public static void main (string[] args) throws Exception {
New will automatically load//drivermanagertest drivermanagertest = new Drivermanagertest ();
After no compile, or clean after the class is not found, the solution described above has been described connection connection = drivermanagertest.getconnection ("Config.properties" ); System.out.println (connection);} public static Connection getconnection (String path) throws IOException, ClassNotFoundException, SQLException { Properties Properties = new properties ();//So the directory read by getResourceAsStream is for the compiled file location, so the following can be written after compilation//InputStream ras= DriverManagerTest.class.getClassLoader (). getResourceAsStream (path); InputStream ras = DriverManagerTest.class.getResourceAsStream ("/" + path), if (RAS = = null) {System.out.println ("connection==nulls"); return null;} Properties.load (RAS); String url = properties.getproperty ("url"); String Driverclass = Properties.getproperty ("Driverclass"); Ras.close ();//Do not get object, or automatic registration Class.forName (DRIVERCLASS); Connection Connection = drivermanager.getconnection (URL, properties); return Connection;}}
A brief analysis of Java's Java-build-path and Maven's Java-build-path