2

I am trying to compile my java project into a .jar file. It contains many (50+) external libraries that I linked into a project subfolder called "lib". I am using vscode with java extension to code and it seems to recognize the libraries fine.

project architecture

Now, if I am trying to use the "build .jar" command from vscode, I get errors saying imported packages does not exist. The default command used by vscode is the following:

rm -rf /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/build-jar && mkdir /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/build-jar && javac -d /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/build-jar /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/src/* && jar cvf /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/build-jar/Run.jar /mnt/data/work/CDYYY-Dev/star-utils/japyCCM/build-jar *

/mnt/data/work/CDYYY-Dev/star-utils/japyCCM/src/Parser.java:6: error: package com.google.gson does not exist

There must be a way to tell the compiler to attach the libs I am using but I dont find any. I only find topics talking about Maven projects but mine is not a Maven project.

I tried to reach the support of vscode java extension but they tell me its not an extension problem and they won't help me. I am getting a bit confused with only answers referring to Maven projects whereas I just want to keep the project as simple as possible and attach my dependencies.

Thank you very much

carlitador
  • 47
  • 9
  • This is what a sourcepath is for. – PiRocks Feb 17 '20 at 09:02
  • See here: https://stackoverflow.com/questions/2441760/differences-between-classpath-and-sourcepath-options-of-javac – PiRocks Feb 17 '20 at 09:03
  • Thank you. I dont see concretely how I need to do to attach the libraries.. – carlitador Feb 17 '20 at 09:12
  • As I said in the description I have nearly 100 external .jar files to include.. Therefore it is not possible for me to add external path in the command line. Do you know an easy and convenient way in my case? Thanks – carlitador Feb 17 '20 at 10:17
  • Almost all java is done with either an IDE and/or maven/gradle. This is part of the reason. Is there a reason you must use vs code and can't use a build system? – PiRocks Feb 17 '20 at 10:28
  • Just to keep things clean and simple. Also, I am working with other developpers who have different working environments. – carlitador Feb 17 '20 at 10:32
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/207969/discussion-between-pirocks-and-carlitador). – PiRocks Feb 17 '20 at 10:38

0 Answers0