Reputation: 3
I have a Maven project that simply reads a CSV file and writes data to another file. When building/running from IntelliJ, it works fine but when I run $ java read.java
from the console, it gives
src/main/java/read.java:1: error: package com.opencsv does not exist
import com.opencsv.CSVReader;
Same thing for CSVWriter
.
I added the .jar to my project but it was not successful. How can I launch my app from console (so I can use arguments as I launch it)?
Thank you
Upvotes: 0
Views: 931
Reputation: 2509
You just need to add the neccesary jars to the classpath.
For example:
java -cp libs/opencsv-5.2.jar read.java
See:
https://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html
Upvotes: 1