views:

1294

answers:

3

Eclipse has a Run Configurations screen with a Classpath tab.

I had some jars listed in the "user entries" section of this tab but my project did not run until I duplicated those jar files into the "bootstrap entries" section. After the jars were listed in both sections, the project ran successfully.

Why?

What's the difference between these two different categories of Classpath settings?

+1  A: 

One of them is for checking the sources/classpaths in the editor, the other is for the runtime environment.

I think.

What the hell, I'm maxed out today anyway.

Charlie Martin
15400 / 200 = 77 days... nice... I think the checkmark should move in this case. :(
ojblass
Well, thanks. My average is way less that 200/day though.
Charlie Martin
+1  A: 

Can you generate the jar file both ways extract them and compare them. I am horribly curious if the jar file changed when you added the entry. Some information on class loading might offer some insight. The specification for jar files doesn't really offer any hints.

ojblass
"Generate the jar file". Not sure what you mean.
Michael Jay
Interesting. The "class loading" link you provided says: "When resolving a class name, the runtime searches files in this order: 1. bootstrap class path 2. extensions 3. user class path"That seems to contradict my experience since, in my case, it seems the user class path was ignored at runtime.
Michael Jay
What about diffing the jars? Any fuit there?
ojblass
Hmmm are you only running from the IDE?
ojblass
Eventually I assume that you are running from java command or jar meaning that you export the jar file... by generating the jar file... I mean exporting it from eclipse in some way with the settings both ways... I want to know if that setting affects the resultant jar file in any way.
ojblass
There really is no telling what lies that IDE is telling to Java when it runs!
ojblass
Maybe that's what eclipse does behind the scenes? After I set the "Run Configuration" I just need to hit the run button. I'm not sure how to generate a jar file for the whole project, if that's what you mean.
Michael Jay
Ok, I tried exporting the project to a jar both ways but the jar looks the same either way. But this raises other questions - like, did I do it correctly - I've never done this before and I had an option to export to a plain jar file or a runnable jar file. I have a feeling the latter is what I needed but I couldn't figure out how to configure it - it requires a "launch configuration" which I don't know how to set.
Michael Jay
Perhaps too involved for this exercise: http://www.coderanch.com/t/105976/IDEs-Version-Control-other-tools/Tutorial-Eclipse-Launch-Configuration
Michael Jay
You can export a jar file by right clicking your project and using the export JAR file feature. I am forced to use eclipse at work and I am at home so I can't verify that. Remember that the compiler setting are independent of the run settings... You can use a different Java version for compling and yet another at run time... I would assume the User settings are in fact only applying to runtime and charlie should get a checkmark by his name. IDEs are pure hell for understanding fundamentals.
ojblass
I think you have learned an important lesson about IDEs. I would be more than curious if a runnable jar is different than a jar and that bootstrap entry might just pop up. There are good tools to compare directories (Windiff might be at hand) so it should not be too hard to compare these. Seriously IDEs are evil sometimes.
ojblass
@Michael, the way that you package up a Java app for later use is to build a single jar file containing all classes, with a MANIFEST file that specifies the class from which to call the public static void main. All this stuff is in the Java Tutorials, which I commend to your attention. http://java.sun.com/docs/books/tutorial/ and see especially the deployment tutorials http://java.sun.com/docs/books/tutorial/deployment/index.html
Charlie Martin
+1  A: 

The difference is the order of their specification in the classloaders.

The bootstrap classpath is managed by the top-level classloader when starting the VM that will execute the app. (From a commandline this is speicfied using -Xbootclasspath)

The user classpath are entries that are managed by the application classloader.

Any entries in the bootstrap classpath take precedence over the user classpath.

These are initialized based on the project containing the application to launch, but you can modify them in the launcher configuration for the application you wnat to launch in eclipse.

As to why it didn't work: what were the jars? Were they things that needed to be loaded from the runtime classes (like xml parser replacement libs?)

See http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html for more details.

-- Scott

Scott Stanchfield