Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between class path , file system?

I know that:

  1. ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

    loads context definition from an XML file located in the classpath, treating context definitions as classpath resources.

  2. ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");

    loads context definition from an XML file in the filesystem.

  3. XmlWebApplicationContext

    loads context definition from an XML file contained within a web application.

But, what does it exactly mean??

Thanks :)

like image 508
Sachin J Avatar asked May 02 '12 10:05

Sachin J


People also ask

What is difference between ClassPathXmlApplicationContext and FileSystemXmlApplicationContext?

ClassPathXmlApplicationContext will read files from your classpath. They must be in classes folder of your web application or in a jar in your lib folder. FileSystemXmlApplicationContext can access all your file system, for example c:/config/applicationContext.

What is difference between Path and CLASSPATH in Weblogic?

Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .

What is meant by CLASSPATH?

Classpath is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable.

What is the use of Path and CLASSPATH in Java?

PATH is used by CMD prompt to find binary files. CLASSPATH is used by the compiler and JVM to find library files.


2 Answers

  • ClassPathXmlApplicationContext will read files from your classpath. They must be in classes folder of your web application or in a jar in your libfolder.

  • FileSystemXmlApplicationContext can access all your file system, for example c:/config/applicationContext.xml.

  • XmlWebApplicationContext certainly can access to files contained in your web application, but this is not the most important thing. It implements WebApplicationContext and this means that it will detect ServletContextAware beans, register custom scopes (request, session, ...) among other things.

like image 100
sinuhepop Avatar answered Oct 18 '22 11:10

sinuhepop


FileSystemXmlApplicationContext- You need to provide complete full path of xml bean ClassPathXmlApplicationContext - In this case you DONOT need to set full path, as long as classpath is set

like image 30
Uday Avatar answered Oct 18 '22 13:10

Uday