Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Anwendungsparameter während der Laufzeit ändern ?

Empfohlene Antworten

Veröffentlicht

Hallo,

ich würde gerne das "Working Directory" während der Laufzeit des Java-Programmes ändern. Hat jemand eine Ahnung ob das geht, und wenn ja, wie ???

Kleines Beispiel:

import java.io.RandomAccessFile;

import java.io.IOException;

import java.util.Properties;

import java.util.Enumeration;

public class theMain {

public theMain() {

}

public static void main(String[] args) {

Properties props = System.getProperties();

String oldworkdir = props.getProperty("user.dir");

String newworkdir ="C:\\";

props.setProperty("user.dir", newworkdir);

System.out.println(props.getProperty("user.dir"));

System.setProperties(props);

try

{ RandomAccessFile output = new RandomAccessFile("test.txt","rw");

output.writeChars("kjhgalsdglegalsjgkhg");

output.close();

}

catch (IOException ex)

{

ex.printStackTrace();

}

catch (InterruptedException ex)

{

ex.printStackTrace();

}

props.setProperty("user.dir", oldworkdir);

System.setProperties(props);

System.out.println(props.getProperty("user.dir"));

}

}

Wäre für eine schnelle Antwort dankbar....

Gruss Rossi

Hallo,

und wo ist nu dein Problem?

Gruß Jaraz

PS: Klassennamen bitte mit einem großen Buchstaben anfangen.

catch (InterruptedException ex) {

ex.printStackTrace();

}

Kannst du weglassen, da der Bereich durch die IOExeption unreachable ist.

Wenn du den Code ausführst, schau mal wo die Datei liegt.

Sie sollte aber unter C:\ liegen. Das ist das Problem. Aber es hat sich schon erledigt.

SUN hat den Fehöler gemacht. Wenn man die System-Props ändert und eine neue Runtime erstellt, sollte die sich auf die neuen Props beziehen. Wie man sieht tut sie das allerdings nicht.

Gruss Rossi

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.