0

I am trying to import a class/classes from a 3rd party library into my computer program. I am working on a windows computer. All worked fine when I used NetBeans originally, but I have started to use command prompt. I can no longer compile one of the .java files. Here is what my directory looks like:

CodeFolder

  • jarLibrary (holds all of my .jar files)

  • db_diff_checker_gui2 (holds all of my .java files)

I run the following from the jarLibrary folder:

javac -cp ".;jarLibrary\jackson-annotations-.0.1.jar";".;jarLibrary\jackson-annotations-2.0.1.jar";".;jarLibrary\jackson-annotations-2.0.1.jar";".;jarLibrary\mysql-connector-java-5.1.44-bin.jar" db_diff_checker_gui2/*.java

However, I get the following error message as a response:

import com.fasterxml.jackson.databind.*;
^
..\db_diff_checker_gui2\FileConversion.java:31: error: cannot find symbol
                ObjectMapper mapper = new ObjectMapper();
                ^
  symbol:   class ObjectMapper
  location: class FileConversion
..\db_diff_checker_gui2\FileConversion.java:31: error: cannot find symbol
                ObjectMapper mapper = new ObjectMapper();
                                          ^
  symbol:   class ObjectMapper
  location: class FileConversion
..\db_diff_checker_gui2\FileConversion.java:48: error: cannot find symbol
                ObjectMapper mapper = new ObjectMapper();
                ^
  symbol:   class ObjectMapper
  location: class FileConversion
..\db_diff_checker_gui2\FileConversion.java:48: error: cannot find symbol
                ObjectMapper mapper = new ObjectMapper();
                                          ^
  symbol:   class ObjectMapper
  location: class FileConversion
..\db_diff_checker_gui2\FileConversion.java:49: error: cannot find symbol
                mapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
                                  ^
  symbol:   variable DeserializationFeature
  location: class FileConversion
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors

I have tried several different ways of running this command, but nothing seems to fix the error. I looked at this question to get the format for the command.

Thank you for your help!

Edit: The duplicate jar files were what was causing the error. I was copying their ,file paths and it seems I was not careful when I was copying the jar file's paths. As a result, when I compiled not all of the necessary files were present.

Peter Kaufman
  • 752
  • 1
  • 6
  • 18
  • Why do you have quotes in the middle of the `-cp` argument? And why have you included the "." directory multiple times? And why did you apparently to include the annotations library three times? – Stephen C Apr 21 '18 at 05:44
  • In addition to the above, you are missing the jackson-databind and jackson-core JARs from the classpath. – Stephen C Apr 21 '18 at 05:53
  • Thank you for pointing out the duplicate jar files. I was copying them from and it seems I was not careful when I was copying the jar file's paths, so it did not have all of the necessary jar files. – Peter Kaufman Apr 21 '18 at 13:27

1 Answers1

-1

Stephen C pointed out that I was not being careful when I had copied all of the jar files over, and I had duplicated several of them and left out others. As a result, when I tried to compile the java files it did not have all of the classes that were being referenced and therefore failed to compile. After adding in the missing jar files, everything compiled and ran as it should.

Peter Kaufman
  • 752
  • 1
  • 6
  • 18