I'm using Visual Studio Code on CentOS 7 and am trying to compile/debug/run the Java Hello sample project in Visual Studio Code. I am able to compile and run the Hello sample project from the command line.
Visual Studio Code is set up with the extensions described here. The Visual Studio Code Java extensions require Apache Maven to be installed, and it appears that, in order to debug Java applications in Visual Studio Code, all Java projects must be set up with a Maven project structure.
I was able to create a working default Maven Java project from within Visual Studio Code. I can compile, set breakpoints and debug, and run that default project. Now I want to bring in the Hello sample project code and compile/debug/run it.
When I copy and paste the original Hello sample project code into my Maven project, this line...
import.com.abbyy.FREngine.*;
...understandably shows a "The import com.abbyy cannot be resolved" error when trying to compile. Obviously, I need to come up with the equivalent for what Hello sample's build.sh
script does:
#!/bin/sh
"$JDK/bin/javac" -classpath ".:..:../../../Inc/Java/com.abbyy.FREngine.jar" \ Hello.java
My understanding is that I need to add com.abbyy.FREngine.jar
to Maven and modify pom.xml
to include that file, as described here. The problem is, I am unable to add com.abbyy.FREngine.jar
to Maven, presumably because it doesn't appear that com.abbyy.FREngine.jar
has a version number.
cd /opt/ABBYY/FREngine12/Inc/Java
mvn install:install-file -Dpackaging=jar -DgeneratePom=true -DgroupId=com.abbyy.FREngine -DartifactId=com.abbyy.FREngine.jar -DVersion=12 -Dfile=com.abbyy.FREngine.jar
It doesn't matter what I set -DVersion to, or even if I eliminate the parameter entirely. I still get the same result, which is this:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.707 s
[INFO] Finished at: 2018-06-08T13:54:49-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: The artifact information is incomplete or not valid:
[ERROR] [0] 'version' is missing.
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
When I check the version number for com.abbyy.FREngine.jar
with this command...
unzip -p com.abbyy.FREngine.jar META-INF/MANIFEST.MF
...I get this:
Manifest-Version:1.0
Created-By: 1.7.0_80 (Oracle Corporation)
My understanding is that neither of these numbers is a version number; if there is a version number associated with this jar, it will be with Implementation-Version
, which is not present here.
I see a similar -- but different -- problem on the forums here but it didn't help (maybe because that problem appears to be addressing the Windows version of Maven?).
Any help would be greatly appreciated!
Comments
2 comments
I was able to solve my issue by adding this entry to the .classpath file:
I also had to move SamplesConfig.java into the same directory as my application code and use the same package name as I used in my application code so it would be recognized.
You can solve the problem as follows. Just add it "-Dclassifier=linux" to the parameters
Please sign in to leave a comment.