Utiliser une API (.JAR) - commande Javac et Java

cs_budhax Messages postés 20 Date d'inscription dimanche 18 août 2002 Statut Membre Dernière intervention 6 septembre 2007 - 30 juin 2007 à 03:59
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 - 30 juin 2007 à 13:56
Bonjour,

J'aimerais tester la méthode getVolumeSerialNumber() trouvée dans cette API:
http://www.servertec.com/products/sfc/docs/stec/sfc/win32/Drive.html
et téléchargeable ici
http://www.servertec.com/products/sfc/download.html  (le binary je suppose)

1. Où placer le setup_fileupload.jar par rapport à ma classe de test ess.java ?
2. Comment importer la classe Drive dans mon ess.java ?
3. Quelle commande DOS (avec le chemin vers le Drive.class) pour compiler ?
4. Quelle commande DOS (avec le chemin vers le Drive.class) pour éxecuter ?

5. Connaissez-vous une autre API permettant d'obtenir le Volume Serial Number ?
Volume Serial Number: celui affiché avec la commande DOS dir

Merci

import java.io.*;
import javax.swing.filechooser.*;

public class ess {
    public static void main(String[] args) {
        String name="";
        File f = new File("C:/");
        //Drive d=new Drive("C:/");
        for (char c='B';c<='Z';c++) {
            //d=new Drive(c+":/");
            //System.out.println(c+":  "+d.getVolumeSerialNumber());
            f=new File(c+":/");
            System.out.println(c+":  "+FileSystemView.getFileSystemView().getSystemDisplayName(f));
        }
    }
}

Dave
A voir également:

2 réponses

gmi19oj19 Messages postés 545 Date d'inscription lundi 10 mai 2004 Statut Membre Dernière intervention 28 septembre 2011 2
30 juin 2007 à 10:00
Salut,

Deux options : soit tu mets ton jar dans ton répertoire qui constitue la racine des packages de ton application
Soit tu mets ce jar dans un reperoire quelconque et tu rajoute ce repertoire au CLASSPATH de ta machine (sous windows : système => avancé => Variables d'environnement )

Je te conseille fortement la seconde qui te permet de réutiliser ton jar sans le copier/coller vu qu'il sera visible partout.

Après, tu n'as plus qu'à faire ts import de la même manière que les import de la bibliothèque standard et à compiler normalement.

gmi19oj19
0
sheorogath Messages postés 2448 Date d'inscription samedi 21 février 2004 Statut Modérateur Dernière intervention 29 janvier 2010 17
30 juin 2007 à 13:56
beurk

pour recuperer tes disque dur :

dans File

public static [file:///C:/jdk/docs/api/java/io/File.html File][] listRoots()

List the available filesystem roots.
A particular Java platform may support zero or more hierarchically-organized file systems. Each file system has a
root
directory from which all other files in that file system can be reached. Windows platforms, for example, have a root directory for each active drive; UNIX platforms have a single root directory, namely
\"/\"
. The set of available filesystem roots is affected by various system-level operations such as the insertion or ejection of removable media and the disconnecting or unmounting of physical or virtual disk drives.

This method returns an array of
File
objects that denote the root directories of the available filesystem roots. It is guaranteed that the canonical pathname of any file physically present on the local machine will begin with one of the roots returned by this method.

The canonical pathname of a file that resides on some other machine and is accessed via a remote-filesystem protocol such as SMB or NFS may or may not begin with one of the roots returned by this method. If the pathname of a remote file is syntactically indistinguishable from the pathname of a local file then it will begin with one of the roots returned by this method. Thus, for example,
File
objects denoting the root directories of the mapped network drives of a Windows platform will be returned by this method, while
File
objects containing UNC pathnames will not be returned by this method.

Unlike most methods in this class, this method does not throw security exceptions. If a security manager exists and its
<code>SecurityManager.checkRead(java.lang.String)
</code> method denies read access to a particular root directory, then that directory will not appear in the result.

<dd><dl>
</dd><dd>* Returns: : An array of
File
objects denoting the available filesystem roots, or
null
if the set of roots could not be determined. The array will be empty if there are no filesystem roots.
* Since: : 1.2

"n'est pas mort ce qui semble a jamais dormir et en d'etrange temps meme la mort peut mourrir"
</dd></dl>
0
Rejoignez-nous