0

I'm new to Java. I need to load model with file (x.bin) , i should put it in config.properties like that

PATH_TO_MODEL_FILE=/home/prog/workspace/My_Project/x.bin

I tried to write

 1   Map conf;
 2   String filepath=(String) conf.get("PATH_TO_MODEL_FILE");
 3   jft.load(filepath); // this line for loading the data from .bin 
       //file and it take string means the path of the file 

but got model file cannot be opening for loading

the file (x.bin) exists in the folder of the project and i should use .jar file this jar after using mvn package but when i packaged the file i didn't find it so i need to make project read it in a correct way except writing the path of the file directly Another thing I have two files except model.bin . The first is data.txt and second is result.txt . Those fiels are in the same path of model.bin . I put there paths in config.properties then used them in the code . My code in distributed mode read the two fiels except model.bin I tried the solution of adding model.bin in jar file and i did it already but error still

  • 1
    NPE because you are not initialize the `conf` variable. Please upload the code you have used instead of a prototype here. – TuyenNTA Jul 17 '17 at 22:35
  • @TuyenNguyen thanks for replying , how can i read the path from properties file because i found this way and tried it ! –  Jul 17 '17 at 22:39
  • Here is an [example of using properties file](https://www.mkyong.com/java/java-properties-file-examples/) – TuyenNTA Jul 17 '17 at 22:42
  • excuse me , i'm confusing . i need to read path of the file from config not loading all of the config –  Jul 17 '17 at 23:06
  • If you do not load file content then how can you get a part of it? You don't want to open the book but you want to read the chapter1? – TuyenNTA Jul 18 '17 at 01:42
  • i edit the post . the error is changed, can you please check it ? –  Jul 21 '17 at 18:44
  • Your problem is package the .jar is missing properties file, then [here](https://stackoverflow.com/questions/9798955/with-maven-clean-package-xml-source-files-are-not-included-in-classpath/9800196#9800196) is the way to solve it – TuyenNTA Jul 21 '17 at 22:06
  • i followed your link and jar now containing the file.bin . but error still model file cannot be opening for loading . I need to tell you that i'm working on distributed mode and the file exists in one of them and jar file which i used it between two machines –  Jul 21 '17 at 23:10
  • I can not catch your real problem, you did not provide any code also the general problem. If you still need help please rearrange your problem in your mind and then present it well in new question in stackoverflow to get help – TuyenNTA Jul 21 '17 at 23:16
  • I will edit the post now . –  Jul 21 '17 at 23:19
  • You should post a new question to reach the others for more help – TuyenNTA Jul 21 '17 at 23:21
  • Does the post after edit will not reach to them ? I'm new here sorry –  Jul 21 '17 at 23:22
  • If a post do not have answer will automatic post again by stackoverflow algorithm but as my point I would like to see newest question then find an old – TuyenNTA Jul 21 '17 at 23:26
  • I post one https://stackoverflow.com/questions/45248149/model-file-cannot-be-opening-for-loading –  Jul 21 '17 at 23:56

0 Answers0