[JAVA-2711] Import sentences throw me an error of not existing package Created: 15/Dec/17  Updated: 11/Sep/19  Resolved: 15/Dec/17

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.6.0
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Luis Ruiz Ruiz Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 16.04



 Description   

I have downloaded the three JAR files to connect to my MongoDB database. I have placed them in a folder of name twitter4j, due to the project I'm currently working on.

I make the imports in my code as follows:

import com.mongodb.async.client.MongoClient;
import com.mongodb.async.client.MongoDatabase;

And I have also tried in this way:

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

following your documentation. But when I try to compile the code, it throws me the following error:

error: package com.mongodb.async.client does not exist for the first case and

error: cannot find symbol
import com.mongodb.MongoClient; for the second one.

I have reviewed the content of JAR files and that classes does not exist in any case.



 Comments   
Comment by Ross Lawley [ 15/Dec/17 ]

Hi lruizr,

Thanks for the ticket. There are various JAR files you can download depending on your requirements:

  • mongodb-driver-async is the asynchronous driver. Normally, your package manager will handle the depedencies, but if downloading mongodb-driver manually, you must also download its dependencies: bson and mongodb-driver-core. See the installation guide.
  • mongodb-driver the synchronous driver. Like the async driver this jar file depends on the bson and mongodb-driver-core. See the installation guide.
  • mongo-java-driver is the uber synchronous jar, contains all the synchronous driver dependencies.

I think the issue you are having is that you don't have the dependencies set correctly your CLASS_PATH.

Just to let you know this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a time frame then we do offer production support.

If you do follow up via one of the options above please post a link and I will follow the conversation there.

All the best,

Ross

Generated at Thu Feb 08 08:57:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.