Java Spring Boot - Read file inside .Jar

1

I'm doing a class that will read an ETL Pentaho Kettle (transformation), I put the file that the class will read in the Resources / KTR folder.

But when I try to run the code as a java (java -jar) application, I get an error saying that the file does not exist,

But it is trying to read the file from the local disk and not from within my .jar

How do I read the file inside .jar?

I'm using Spring Boot 2.1.0.BUILD-SNAPSHOT and Java 1.8

public class run_tranform {

 public static void main( String[] args ) throws IOException
    {
     String file="src/main/resources/KTR/transformation.ktr";

        try {
            KettleEnvironment.init();
            //TransMeta metaData = new TransMeta(file.getPath());
            TransMeta metaData = new TransMeta(file);
            Trans trans = new Trans( metaData );
            trans.execute( null );
            trans.waitUntilFinished();
            if ( trans.getErrors() > 0 ) {
                System.out.print( "Error Executing transformation" );
            }
        } catch( KettleException e ) {
            e.printStackTrace();
        }
    }

 }
    
asked by anonymous 27.08.2018 / 21:21

0 answers