Also, meine Paketstruktur ist, dass ich einen src-Ordner mit meinem Code habe und darin einen exec-Ordner habe eine Klasse und drei Methoden, meine Hauptklasse und zwei Gläser.Kompilieren von jar vom Terminal, Ausnahme: "error: package au.com.bytecode.opencsv existiert nicht '"
Meine exec Klasse sieht wie folgt aus:
package com.xxx.exec;
import au.com.bytecode.opencsv.CSVReader;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
* Created by xxx on 24/07/16.
*/
public class ApiAccess {
public void getConsoleInput() throws Exception {
Console console = System.console();
if (console == null) {
throw new Exception("Unable to fetch console");
}
System.out.println("Please enter the location:");
getAPIData(console.readLine());
}
private void writeCsv(InputStream input) {
try {
CSVReader locationData = new CSVReader(new InputStreamReader(input));
locationData.close();
System.out.println(input);
}
catch (Exception e) {
System.out.println("Something went wrong while creating the csv:" + e);
}
}
private void getAPIData(String location) throws IOException {
String url = "http://exec.goeuro.com/exec/v2/position/suggest/en/";
String charset = StandardCharsets.UTF_8.name();
String query = String.format(url + "%s", URLEncoder.encode(location, charset));
URLConnection connection = new URL(query).openConnection();
connection.setRequestProperty("Accept-Charset", charset);
// String line;
// StringBuilder text = new StringBuilder();
// BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
// while((line = reader.readLine()) != null) {
// text.append(line).append(" ");
// }
//
// writeCsv(text.toString());
writeCsv(connection.getInputStream());
}
}
Mein Terminal-Befehl wie folgt aussieht:
javac -cp ".:lib/*:opencsv-2.41.jar" -d src $(find ./src/* | grep .java)
Und ich bekomme diese Fehlermeldung:
./src/com/goeuro/exec/ApiAccess.java:3: error: package au.com.bytecode.opencsv does not exist
import au.com.bytecode.opencsv.CSVReader;
^
./src/com/goeuro/exec/ApiAccess.java:29: error: cannot find symbol
CSVReader locationData = new CSVReader(new InputStreamReader(input));
^
symbol: class CSVReader
location: class ApiAccess
./src/com/goeuro/exec/ApiAccess.java:29: error: cannot find symbol
CSVReader locationData = new CSVReader(new InputStreamReader(input));
^
symbol: class CSVReader
location: class ApiAccess
3 errors
Danke im Voraus für irgendwelche Antworten!
Aktuelle dir Struktur (Ich habe einen umgekehrten Schrägstrich vor Verzeichnisse):
/src >
-/com.xxx >
-Main.java,
-/exec >
-ApiAccess,
-opencsv-2.41.jar >
-/au.com.bytecode.opencsv,
-commons-lang3-3.0.1.jar
Bitte zeigen Sie uns die Speicherorte der JAR-Dateien relativ zum aktuellen Verzeichnis an. –
@StephenC Hey, ich habe die Struktur hinzugefügt :) – Ozymandias
Ich warte auf Sie zu beheben, so dass es 1) lesbar und 2) genau ist –