2

Most resources online tell me add the Maven dependencies, but I haven't found a working description on how I use the Jackson jar file once I've downloaded it into my project.

I'm a beginner in Java. Thank you for your help.

As simple as possible:

enter image description here

How to write an import into a java file to use the jar file from this location?

sevku
  • 63
  • 1
  • 1
  • 10
  • Please take a look https://maven.apache.org/guides/getting-started/ > Marking this Off-Topic. [Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.] – Naman Mar 06 '17 at 04:04
  • Sorry but this is not Off-Topic, please remove the marking. I am looking for a very specific answer which I can not find elsewhere. Please explain to me what you didn't understand. I'm really looking for someone who can help me with my problem. – sevku Mar 06 '17 at 04:06
  • Please explain why. Add some details to the question, would retract if the question improves. – Naman Mar 06 '17 at 04:07
  • Please explain what you don't understand. I said I've imported the .jar file for Jackson and don't know how to use it (correctly importing it into a Java file). I would really like to get an answer, because I'm stuck with this. – sevku Mar 06 '17 at 04:08
  • 1
    Sounds to me like you're asking for a Jackson tutorial. – shmosel Mar 06 '17 at 04:09
  • I'm asking for a simple straight forward answer to a question that is most likely pretty simple to answer for someone who understands what I mean. – sevku Mar 06 '17 at 04:10
  • "I bought a car. Please explain how to use it." That type of question is vague, broad, and can't be properly answered without lengthy hands-on lessons. Therefore it's not considered on-topic for a Q&A site. If you're asking something more specific, we have yet to see what it is. – shmosel Mar 06 '17 at 04:12
  • @sevku Could you please specify which IDE you are using? – Pratik Ambani Mar 06 '17 at 04:14
  • Look, I know I am stupid in some things, but it's not the way that you understand it. I've tried to update the question. This is a honest question and there is nothing I can find that works for me. So please, just try to answer my question. – sevku Mar 06 '17 at 04:14
  • *How to write an import into a java file to use the jar file from this location?* You don't import a jar, you import a class. Which class do you want to use? – shmosel Mar 06 '17 at 04:15
  • @PratikAmbani I am using Eclipse JEE and I've downloaded the jackson-core-2.8.7.jar into my project libraries folder. – sevku Mar 06 '17 at 04:15
  • @shmosel basically I need to know what the path is to the downloaded jar file so that I can import the classes that I need. Does that make any sense at all? :/ – sevku Mar 06 '17 at 04:16
  • @sevku Make sure you've gone through all steps mentioned in following link. http://stackoverflow.com/a/13640110/7212399 – Pratik Ambani Mar 06 '17 at 04:18
  • @shmosel for example the JsonParser but not exclusively. – sevku Mar 06 '17 at 04:18
  • @PratikAmbani thank you. I've tried installing Maven several times and I've given up on that. It just doesn't work on my machine and I can not tell why. That's basically why I'd prefer to download the jar files directly, which I've done with the jackson-core-2.8.7,jar file. – sevku Mar 06 '17 at 04:19
  • @PratikAmbani I've done the things that are said in the link and it tells me that all of that is already installed. – sevku Mar 06 '17 at 04:21
  • 1
    That would look like `import com.fasterxml.jackson.core.JsonParser;`. This is really basic stuff, if you'll excuse my saying so. – shmosel Mar 06 '17 at 04:22
  • @shmosel, Thank you very very very much. It looks like that's exactly the answer I was looking for. And yes it must be very basic stuff. I'm an absolute beginner. I'm very grateful for your patience. I'll try it and hope it all works. :/ – sevku Mar 06 '17 at 04:26
  • @sevku the problem with this question is there are multiple steps you need to take and depending on the circumstances there are different answers for each step. 1. You download the jar 2. You import that class in your own class which has the dependency. 3. You include the jar in your class path when you compile your project. Your simple question has a lot of related questions that are not easily answered. You should create multiple questions asking each part in specific. For example, "How do I find the package of a class that I want to import?" and "How do I include a jar in my class path?" – Rawr Mar 06 '17 at 04:29
  • @sevku my answer below. – Pratik Ambani Mar 06 '17 at 04:29
  • @Rawr, I think my actual question started after the ones you mentioned - I've already included the jar file into my Build Path but couldn't really do anything with it. The simple "import path" or however you call it given by shmosel and the explanation from PratikAmbani helped me solve the problem. Thank you everyone for you patience. – sevku Mar 06 '17 at 05:32

2 Answers2

4

What I understood by your post is that you are not able to access any class of a library you've imported into your workspace.

Follow mentioned steps, Right click on your project --> Properties --> Java Build Path --> Libraries --> Add External Jar --> Choose jackson-core-2.8.7.jar which you've recently downloaded and that's it.

Now go to your Java Class where you need any class of jackson library and import the class from the library you need to use/extend. Refer screenshot attached below for further reference.

enter image description here

Pratik Ambani
  • 2,523
  • 1
  • 18
  • 28
  • Thank you! the autocorrect for the import com.* is exactly what will hopefully help me out next time! – sevku Mar 06 '17 at 04:33
  • 2
    @sevku If you type out the class name in your code and hit ctrl + space, eclipse will suggest matches and automatically import the one you select. – shmosel Mar 06 '17 at 04:42
1

The question was answered in the Answer comments by @shmosel

import com.fasterxml.jackson.core.JsonParser;

The answer by @Pratik Ambani is very useful too.

Also, not just the jackson core has to be imported but also databind and annotations.

The files can be found here: http://repo1.maven.org/maven2/com/fasterxml/jackson/

sevku
  • 63
  • 1
  • 1
  • 10