2

I've a problem, I must compile a java project (example: https://github.com/iluwatar/java-design-patterns/tree/master/bridge) but it's a maven project and i must import slf4j.

I've tried with sudo apt-get install libslf4j-java or by downloading manually the package (here: https://www.slf4j.org/download.html) but it never work when I use javac.

I get this error: error: package org.slf4j does not exist

Do you have any ideas? I'm stuck on this error and I haven't found any similar issues...

EDIT : The goal is to compile without maven, that's the hard thing for me.

EDIT2 : I've done this :

javac -cp /usr/share/maven/lib/slf4j-simple.jar:java-design-patterns/bridge/src/main/java/com/iluwatar/bridge/App.java
javac: no source files
Usage: javac <options> <source files>
use -help for a list of possible options

javac -cp -sourcepath /usr/share/maven/lib/slf4j-simple.jar:java-design-patterns/bridge/src/main/java/com/iluwatar/bridge/App.java
javac: file not found: /usr/share/maven/lib/slf4j-simple.jar:java-design-patterns/bridge/src/main/java/com/iluwatar/bridge/App.java
Usage: javac <options> <source files>
use -help for a list of possible options

I don't know what to do, it's so simple with maven, when i see this i'm just lost.

I've create 2 files : jars (where i will create and put jars) and temp (where i will create and put class)

EDIT 3 : I downloaded the package and put it at the . Then i use : javac -classpath slf4j-1.7.25/slf4j-api-1.7.25-sources.jar -d temp java-design-patterns/bridge/src/main/java/com/iluwatar/bridge/*.java and it worked fine.

Samix
  • 79
  • 10

1 Answers1

1

Compiling from command line must be done invoking javac and properly passing arguments:

javac -cp lib1.jar:lib2.jar:lib3.jar... <source files>

In your case:

javac -cp /usr/share/maven/lib/slf4j-simple.jar java-design-patterns/bridge/src/main/java/com/iluwatar/bridge/*.java

P.S.: Compiling trhough command line is really annoying. I recommend you to use Maven, since it is already a Maven project.

Little Santi
  • 8,563
  • 2
  • 18
  • 46