I find a project in Eclipse has it own class path.
If i use maven create a new web project.
System.getProperty("java.class.path"); When i print the result, I find the class path contains G:\newtool\workspace\springmvc\target\classes.
Who can explain the principles behind it.Why the class path is this directory. Is the build function of Eclipse same as the command,javac -classpath?
And i find another question.
public class KnightMain { public static void main(String[] args) throws Exception { System.setProperty("java.class.path","G:/newtool/workspace;G:/newtool"); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("knight.xml"); Knight knight = context.getBean(Knight.class); knight.embarkOnQuest(); String s[] = System.getProperty("java.class.path").split(";"); for (String string : s) { System.out.println(string); } context.close(); } }
Although i set the class path to other directory where the knight.xml is not exist.But ClassPathXmlApplicationContext find it finally.Why the
System.setProperty("java.class.path","G:/newtool/workspace;G:/newtool"); makes no difference.Although the print result is:
G:/newtool/workspace G:/newtool