Aller au contenu
View in the app

A better way to browse. Learn more.

Next

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.

Java : accèder au répertoire de l'application

Featured Replies

Posté(e)

Bonjour,

je cherche un moyen d'acceder en absolu au répertoire oú se situe mon application Java à partir de l'application même. (éxécution d'une commande DOS et création d'un fichier dans ce répertoire).

Pour exemple ma commande s'apparente à ceci :

cmd = path+"bin\\mysqldump -u "+login+" -p "+password+" "+base+" > "+ [ce que je cherche];

try {

Runtime r = Runtime.getRuntime();

Process p = r.exec(cmd);

p.waitFor();

}catch(Exception ex) {

System.out.println("erreur d'execution " + cmd + e.toString());

}

Posté(e)

Pas du tout... Ta commande te donne le répertoire personnel de l'utilisateur (/home/XXX sous linux, C:/Mes documents/... sous windows).

Si tu lances ton appli à partir de ce répertoire c'est bon, sinon c'est raté.

Ma commande en revanche te donne véritablement le répertoire racine de ton application.

Posté(e)

Dixit l'API 1.4.2 de Sun (classe System).

user.name User's account name

user.home User's home directory

user.dir User's current working directory

Exemple :

package com.test;

/**
* @author fabien
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Test
{

public static void main(String[] args)
{
	System.out.println("Repertoire courant :");
	System.out.println(System.getProperty("user.dir"));
}
}

Lancement :

fabien@Dauntless /usr/src $ java -cp /home/fabien/test.jar com.test.Test
Repertoire courant :
/usr/src

Désolé Sentinel :mdr2:

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

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.