IntelliJ - .properties in jar einbinden

Hallo,
ja, der Titel sagt eigentlich eh schon alles... :-D Ich hab ein Programm geschrieben, welches einen ConnectionString aus einer .properties-Datei auslesen soll. Wenn ich das Programm von IntelliJ aus starte, ist alles ok, sobald ichs in der Console mit java -jar "MeinProgramm" starte, kommt sofort die FileNotFound Exception. Wenn ich die .jar Datei extrahiere, ist da auch keine .properties-Datei drinnen... k.a. warum -.-

Hat jemand einen Tipp für mich?
Thx & Lg
buzzzzz
 
Ich hab mein Program "MyProgram" hier sind die Ordner src (mit den Sourcen), der Ordner res, out (mit sämtlichen Dateien, da drinnen entsteht auch die .jar Datei.) Ich hab die Datei .properties bereits im Hauptordner "MyProgram" in "src" und "res" gelegt, leider ohne Erfolg.
 
Ich habe eine Klasse die nennt sich ProgramProperties, da hab ich eine Methode die getConnectionString heißt. Der Zugriff erfolgt so:
Java:
InputStream stream = new FileInputStream(".properties");
java.util.Properties prop = new Properties();
prop.load(stream);
String connectionString = properties.getPropertiey("connectionString");
Wenn ichs von IntelliJ aus starte, funktioniert auch alles wunderbar... nur in der Jar bekomme ich halt immer die besagte Exception.

Thx & Lg
buzzzzz
 
Oh, ein guter Ansatz:


P.S Assume properties file “config.properties” is in your project classpath root folder.


werd ich nachher mal probieren... vllt brauchts sonst ja auch noch wer. Meld mich nochmal!

Thx & Lg
 
Ok, die .properties ist jetzt in der jar drinnen... jetzt kann er allerdings wieder nicht auf den gewünschten Inhalt zugreifen, zumindest kommt jetzt die FileNotFound-Exception nicht mehr. Ich hab sie jetzt in einen res-Unterordner gelegt und auch die Strings angepasst. Hat noch jemand einen Tipp wo da in der .jar der Unterschied ist?

Thx & Lg
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
krgewb IntelliJ - Zu application.properties springen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
D Intellij source controll zeigt nicht alle klassen an ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
MiMa Die Sourcecode Verzeichnisse verschwinden in IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
M Eclipse oder IntelliJ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
krgewb IntelliJ durchsucht .log-Dateien IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
Oneixee5 IntelliJ JavaEE IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
krgewb GUI-Elemente in IntelliJ verschwunden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
MiMa IntelliJ Projekt umbenennen?? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
MiMa IntelliJ dubious ownership in reposity? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
JAnruVA IDEA IntelliJ JavaScript in IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
D Crawler funktioniert in intellij aber in Eclipse nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
W Speicherbelegung in IntelliJ auswerten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
N generate selected getters with intellij IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
MiMa Netbeans zu IntelliJ mit Maven konvertieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
temi IDEA IntelliJ Intellij new UI IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
D strg + alt + B funktioniert nicht [IntelliJ] IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
MiMa IntelliJ Maven Projekt erstellen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
MiMa IntelliJ GIT-Verzeigung zu Master hinzufügen? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
MiMa Nebtbeans Projekte nach IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
L source folder und code highlighting IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 21
D lesen von json Dateien in Intellij IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 13
MiMa Doppelten Code in IntelliJ finden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
H Branches vergleichen - GIT, IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
frager2345 Datenbankzugriff Intellij IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
Y IDEA IntelliJ Warum findet IntelliJ die maven property nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
J IntelliJ IDEA IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
krgewb IntelliJ Idea - Alles eingeklappt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
LimDul IDEA IntelliJ Tipps für den Umstieg von Eclipse auf intelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
F IntelliJ IDEA Community Edition IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 26
S IDEA IntelliJ GUI Component Tree anzeigen in IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
D Intellij Memory Settings IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
krgewb In IntelliJ alles eingeklappt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
N IDEA IntelliJ Intellij lässt keine neuen archetypes erstellen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
S IDEA IntelliJ Scenebuilder in Intellij Idea am MAC OS X IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
OnDemand IntelliJ Branching Master/DEV Berechtigungen möglich? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
9 IDEA IntelliJ Wie kann man ein JUnit Test bei IntelliJ durchführen? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 11
9 IDEA IntelliJ IntelliJ lässt nicht ein Code ausführen, wenn irgendwo in andere Klasse Fehler ist. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 12
O IntelliJ IDEA Lizenz IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 15
D Intellij mehrere Programme in einem Projekt bearbeiten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
M Intellij build jar funktioniert nicht ! IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
Z Intellij zeight H2-Datenbank nicht an IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 9
P Maven für Intellij IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
P Intellij "httpRequest" ins Projekt mit einbinden? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 49
temi IntelliJ, Gradle und Git: gitignore IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
N Frage zu meinen IntelliJ-Einstellungen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
mrBrown IntelliJ 2020.1 - Maven Projekte nicht ausführbar IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
W IntelliJ soll nicht immer alle Code-Files checken IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
Thallius Falsches Warning in IntelliJ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 14
D JavaFX 12 / SDK 12 -> IntelliJ error IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 7
R IDEA IntelliJ Intellij klaut mir zu viel zu viel Speicherplatz weg! IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 22
M Intellij IDEA lädt Font nicht und Darcula funktioniert nicht IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
M Intellij IDEA Programm ohne Main-Methode starten IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
Y Intellij mit Android SDK IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
E Maven-Installation für Intellij IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
U IDEA IntelliJ IntelliJ IDEA automatische Formatierung deaktivieren IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
K IntelliJ unter Linux: Probleme beim Ausführen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
M Idea IntelliJ - Starten der Mainmethode ? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
A IDEA IntelliJ IntelliJ Maven oder Webprojekt, kann keine normalen Java Klassen erstellen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
K IDEA IntelliJ Umstieg von ADT (Eclipse) auf Android-Studio (IntelliJ IDEA) IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
R intellij idea mit SVN tortoise 1.8 verwenden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
X "Extract Method Object" aus IntelliJ auch in Eclipse? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
U [IntelliJ] Variablen Refactoring IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
H Intellij 8.1.3 JDSK Probleme IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
S Metriktools für IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
M Grails Plugin in IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
A IntelliJ zeigt meine class-Files nicht an!? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
L Intellij IDEA 8 - Wie ist eure Meinung? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 38
J IDEA IntelliJ IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 10
G IDEA IntelliJ Problem IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
krgewb Kein Sprung (per STRG + Mausklick) von application.properties möglich IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
krgewb IDEA IntelliJ Es kann nicht zu Properties gewechselt werden. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
J Gradle add Bom Properties IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
N log4j.properties in build.xml angeben IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
B Probleme mit Properties Files in Netbeans IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
reibi SVN Properties rekursiv vererben IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
K Eclipse Strings externalisieren -- properties-Dateien in separatem Ordner? IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
Z NetBeans JTextfield Properties IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
reibi Eclipse Suche : in *.properties/gebunden in jars IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
O Methoden und Properties werden doppelt angezeigt IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3
D Methode in Eventhandler per Properties IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
B Eclipse --- Localies - Properties-Dateien vergleichen IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
M Eclipse-Plugin: Properties-File IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 1
A Properties Syntax IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
K Eclipse löscht die Datei Log4j.properties im WEB-INF/classes IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
J Eclipse CDT Library einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
nonickatall paho.client.mqttv3 in Eclipse installieren/einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 8
A JavaFX in Eclipse einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 22
D IDEA IntelliJ Dokumentation von Libaries einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
robbin IDEA IntelliJ fremde/externe Bibliothek einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
A Jar erstellen und einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
X Eclipse Einbinden von Bildern bei .jar IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 6
X Plugin lässt sich nicht einbinden.. IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 0
B IDEA IntelliJ JDK wird nicht erkannt und lässt sich nicht einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
T Eclipse Java-Klassen aus dem einen in ein anderes Projekt einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
I Eclipse WindowBuilder Grafiken (icons) einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
El_Lobo Eclipse LAF jar file einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 2
H NetBeans Library in JAR einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
M Eclipse Webstart plugin einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 5
T Eclipse Java src einbinden IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 4
C NetBeans Libaries im projekt einbinden?! IDEs - Eclipse, IntelliJ IDEA, BlueJ & mehr 3

Ähnliche Java Themen

Neue Themen


Oben