Questions tagged [classpath]

In Java, the classpath tells the Java Virtual Machine where to look for user-defined classes and packages when running Java programs. The classpath is a parameter and can be set either on the command-line, or through an environment variable.

When executing Java programs, the JVM uses a method that is similar to classic dynamic-loading. That is, the JVM lazily finds and loads classes (meaning, the JVM loads a class only when it is first used). The classpath tells the JVM where to look for the files that define these classes, on the filesystem.

The JVM searches for and loads classes in the following order:

  • Bootstrap classes: These are fundamental classes belonging to the Java platform. These are public classes that belong to the Java Class Library, and it also includes the private classes that are necessary for this library to function properly.
  • Extension classes: These are packages that are in the extension directory of either the JRE or the JDK (usually in jre/lib/ext/).
  • User-defined packages and libraries: These are packages and libraries that are created by the user or that are being used by the user. These can include third-party libraries.

Packages from the JDK standard API and extension classes are accessible by default (the classpath doesn't need to be explicitly set to provide access to them). However, the path for all user-defined packages and libraries must be set. This can be done either via the command-line, an environment variable, or in the manifest file associated with the JAR file that contains the classes.

4839 questions
2
votes
1 answer

How to load Spring context xml from a jar file

I am running a Junit (SpringJUnit4ClassRunner) to access some spring beans in my integration test. I need to load a few xml files via @ContextConfiguration, those files are deployed by a external approach to my Tomcat directly via a jar file. -- In…
Ye Huang
  • 639
  • 2
  • 10
  • 21
2
votes
2 answers

Class path issue: NoClassDefException :

Here's the issue, i have this one project X that uses another project Y's services. Y was exported as jar file using eclipse and added to the project X build path. it so happens that the class that the spring loads "classService" in X can't load…
Vik2r
  • 145
  • 1
  • 2
  • 7
2
votes
0 answers

classpath mess when deploying war with org.eclipse.jetty.server.Server

I am using org.eclipse.jetty.server.Server to start jetty and deploy war. I have something like this: class Runner { private static void run(String[] arg) { Server server = new Server(); ... server.setHandler(webApp); …
pavko
  • 51
  • 3
2
votes
0 answers

How to add an xml of a dependant project in eclipse

I currently having an applicationContext.xml of an existing project. I created a new junit -Java project in which I kept the previous project as dependent project. I created an xml -ApplictionContextjunit.xml for the junit project.The question is-…
Saurav
  • 111
  • 1
  • 4
2
votes
1 answer

Using JavaCompiler with Classpath referencing jars within ear

I am working on a project in which an enterprise archive (ear) deployed on a JBoss server needs to compile (and run) a class dynamically. I am using the JavaCompiler class to do this - the complication comes from the fact that the class being…
Russell
  • 199
  • 1
  • 1
  • 7
2
votes
1 answer

Xtext Project: Add Jar Libraries with the Project Wizard Manager into the Classpath/Referenced Libaries of the clients Project

I have been searching quite a lot for this problem, however I can't really find a proper solution or a how-to manage this one. I have written a simple DSL for generating some code via Xtext and Xtend. I optionally use the project wizard in the UI…
2
votes
5 answers

In eclipse, how can I find where in my classpath a type is coming from?

Maybe I'm misunderstanding something, but.. I want to be able to see that eclipse is getting Foo.class from a .jar (somewhere in the classpath) when it builds project B. If I use the 'open type' (Ctrl + Shift + T) it seems that that just shows me…
Bruce
  • 2,406
  • 5
  • 29
  • 35
2
votes
1 answer

java set classpath from php

I have this folder structure C:\a\b.java C:\a\b.class C:\a\c.java C:\a\c.class C:\a\ftp.jar From PHP, I used exec("java b"); This executed b.class file. That is fine. Now I should execute c.class file from PHP. In c.java, I have created an object…
user2314387
  • 265
  • 2
  • 4
  • 10
2
votes
2 answers

Adding properties file to classpath but getting a FileNotFoundException

My spring context file has this: and I reference the key/values like: My file layout is…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
2
votes
3 answers

Linking an external .jar from an Xcode java project?

How do I link an external .jar into my Xcode java project? That is, have it in the classpath during compilation and execution. I'm using Xcode 3.0 and this seems to have changed since 2.4.
mellis
  • 4,621
  • 4
  • 22
  • 10
2
votes
3 answers

Add items to application (WAR) classpath in WebLogic 10?

My shop has been running Oracle's Application Server for several years. As such, before we knew better, we have developed a norm of having application config files stored outside of the WAR file and the app-specific config directory is added to each…
Randy
  • 21
  • 1
  • 1
  • 2
2
votes
2 answers

How to reference apache cxf library from apache web server

When I deploy my apache cxf web service using eclipse I have to include the apache cxf library in the Web Deployment Assembly in order for it to work when I deploy it on my production apache web server. This is a problem because it makes the war…
jesman3
  • 31
  • 3
2
votes
1 answer

Problems with jar file

The problem isn't creating the jar file but to make it work. Because I use Java 3D i need the jar file to get the Java 3D classes but I can't seem to get it to work. I have set up the classpath properly and I have also tried to set the class path in…
programmer
  • 199
  • 3
  • 18
2
votes
2 answers

Adding spring XML files to classpath (Windows cmd-line)

I am trying to run a jar file via cmd line that uses Spring and a spring xml configuration file. The cmd line call is similar to: java -cp lib/MyJar.jar my.package.MyClass The error I get is: Caused by: java.io.FileNotFoundException: class path…
user973479
  • 1,629
  • 5
  • 26
  • 48
2
votes
1 answer

How to get ResourceBundle files out of classpath?

I am using a ResourceBundle for different languages (en, de, fr, ...) and the Keys are listed in a .properties file. It works great, but only using the classpath in the function getBundle(). Now, if I build my project as an executable JAR file, I…
marc3l
  • 2,525
  • 7
  • 34
  • 62
1 2 3
99
100