Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334293 - Add a library in Build Path not work in ClassPath
Summary: Add a library in Build Path not work in ClassPath
Status: NEW
Alias: None
Product: Data Tools
Classification: Tools
Component: Connectivity (show other bugs)
Version: 1.8.1   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: future   Edit
Assignee: dtp.connectivity-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-13 12:28 EST by Giovanni Cândido CLA
Modified: 2021-10-09 08:48 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Cândido CLA 2011-01-13 12:28:54 EST
When I add one library to the build Path, this library is not included in class path, and a can not include manualy in Run Configurations because they simple don't include.
This cause a Class Not Found Exception in run time that is hard to solve.
I'm try to include data drivers like derby and mysql. I create a conectivity configuration in data source explorer and it works, but in the project using the same library and conectivity configuration throw the Class Not Found Exception.
I don't have idea of why this happens.


-- Configuration Details --
Product: Eclipse 1.3.1.20100913-1228 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.jdt 3.6.1.r361_v20100714-0800-7z8XFUSFLFlmgLc5z-Bvrt8-HVkH
Comment 1 Walter Harley CLA 2011-01-13 15:54:55 EST
Can you include steps to reproduce this problem?

What kind of project are you talking about?  Is this a Java project, J2EE, Web, ... ?

Is this happening for all libraries that you try to add, or only for a particular library?

What do you mean when you say "can not include manually in Run Configurations because they simple don't include"?  Do you mean that you are unable to add the library to the runtime classpath in the launch configuration, and if so, why not (what happens when you try)?

It is true that the build time classpath and run time classpath are different, and are governed by different settings.  That is the way Java works.  The same thing would happen if you were working at the command line: you would have one classpath for when you compile (with javac), and a different one when you run (with java).  I am not sure if that's the issue you are describing, or if it is something else.
Comment 2 Olivier Thomann CLA 2011-01-13 18:11:50 EST
Jay, please follow up.
Comment 3 Giovanni Cândido CLA 2011-01-14 17:24:17 EST
The project is a jpa project.
I do the follow:

*Create a jpa project
*Create an eclipselink library.
*Create one simple testEntity class  and one test class with main method
*Add instructions to persist the testEntity
*Configure build Path > add library > Connectivity Driver Information 
*Create a derby embedded drive that pois to the derby.jar
*Add to project.
*Run the application. And Works
*Now create a second library in the same way for derby but now with mysql jdbc driver and get a "Configuration error.  Class [com.mysql.jdbc.Driver] not found".

After I try to include the library in classpath in: Run Configurations > Java Application > test > ClassPath > User Entries. Click in "Advanced", mark "Add Library","Connectivity Driver Information", choice the connection created, click in finish.
The Window close normal, but library don't list in classpath, and problem continue.
In alternative The option for add external jars in classpath works and problem solved.

In Database Connections, the connection appear and works fine.

As alternative I am using maven and m2eclipse plugin for manager dependencies and libraries and works fine for me.

I think is a problem only with Connectivity Driver Information when try to add a second library to a project
Comment 4 Jay Arthanareeswaran CLA 2011-01-17 00:49:14 EST
(In reply to comment #3)
> The project is a jpa project.
> I do the follow: ...

I think I noticed this the first time I added two database driver libraries to a project (I used a simple Java project, though). When I removed the only library that was visible in the project explorer and tried adding them both again, things appeared to be alright.

Moving to Data Tools for investigation.
Comment 5 Brian Fitzpatrick CLA 2011-01-17 09:35:50 EST
That's very odd. Can you provide a succinct set of repro steps for this one and I'll take a look.
Comment 6 Per Olav Kroka CLA 2021-10-09 08:48:25 EDT
I believe this problem still exists.

I have a similar problem.  I am trying to add JavaFX (I am sure this applies to other libraries as well) to the class path. But I get errors in my code.

Expected behaviour: When the class path pointing to the folder of the JARs, no errors should be shown in a "perfect" code.
 
(Workaround: see the bottom.)

My environment:
 - Ubuntu 20.04
 - Eclipse IDE for Java Developers (version 2021-09)
 - Installed JavaFX into a private (project external) folder. (<https://download2.gluonhq.com/openjfx/17.0.0.1/openjfx-17.0.0.1_linux-x64_bin-sdk.zip>)

 - (it is recommended to install the e(fx)clipse package from eclipse marketplace but for demonstration purpose, this is not used)

Procedure
 - Open eclipse
 - Create a Java project (I created a module as well)
 - Add a new Java class Main in package app.
 - Replace the code in Main.java with the following:
--- Start of text ---
package app;

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;

public class Main extends Application {

	@Override
	public void start(Stage primaryStage) {
		try {
			BorderPane root = new BorderPane();
			Scene scene = new Scene(root,400,400);
			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
			primaryStage.setScene(scene);
			primaryStage.show();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		launch();
	}
}
--- End of text ---
 - Replace the module-info.java with the following:
--- Start of text ---
module classpathTest {
	requires javafx.controls;
	
}
--- End of text ---

(I believe that this is the minimum JavaFX program that displays a window.)


Errors:
  Errors are indicated.  Lets try removing them by specifying a Class path

  - Open the Project Properties and go to "Java Build Path" tab "Libraries"
  - Select (either) Modulepath or Classpath (seems not to matter)
  - Add External Class Folder...
  - Find the lib subfolder in the your JavaFX folder and choose it.
  - Apply and Close

  The same errors are still indicated.  Lets try removing them by specifying a 
  list of JARS first under "Classpath":

  - Remove the class path specification
  - Select Classpath
  - Add External JARs...
  - Find the lib subfolder in the your JavaFX folder and choose the JAR files
    there.
  - Apply and Close
 
  The same errors are still indicated.  Lets try removing them by specifying a 
  list of JARS first under "Modulepath"

  - Remove the JARs under Classpath
  - Select Modulepath
  - Add External JARs...
  - Find the lib subfolder in the your JavaFX folder and choose the JAR files
    there.
  - Apply and Close

  All errors have now disappeared.  This is the expected behaviour when 
  selecting a class path (or maybe module path).

  This also works if the JARs are specified through a User Library.  I believe,
  in this case, it was not dependent on whether it was under the Classpath or 
  the Modulepath headline.