vrijdag 7 februari 2014

Java Deployment en Properties file

how to include an external jar program using eclipse?


You can do this by writing a manifest for your jar. Have a look at the Class-Path header. Eclipse has an option for choosing your own manifest on export.
==> deze optie lijkt niet helemaal goed te werken 


The alternative is to add the dependency to the classpath at the time you invoke the application:

java  -cp ftptest.jar;jsch-0.1.50.jar wagener.jamil.sftp.Sftp


Een veel snellere manier is via de optie Runnable Jar.


Hoe properties in aparte file meegeven


- maak een properties file sftpconfig.properties aan en zet in dir WEB-INF

user =dmo
password =

- maak een classe die deze properties file uitleest


    public static Properties getSFTPConfig()
    {
       
        Properties prop=new Properties();
        InputStream input=null;
       
       
            File f = new File(System.getProperty("user.dir"));             
            String filename="WEB-INF/sftpconfig.properties";
            try {
                input= new FileInputStream(filename);
                prop.load(input);                           
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return prop;
       
    }


maak een classe die aanroept


    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String remotefile;
        Properties sftpconfig;
        sftpconfig = getSFTPConfig();
        String user = sftpconfig.getProperty("user");








Geen opmerkingen:

Een reactie posten