1

Created small Java application using Netbeans IDE.
In package cntp is my source file from which i load neural network:

NeuralNetwork myNeuralNetwork = NeuralNetwork.load("src\\nwork\\nfile.nnet");

This static method has 2 overloads:
public static NeuralNetwork load(String filePath);
public static NeuralNetwork load(InputStream inputStream);

I placed file nfile.nnet in nwork package.

Everything works when i run application from Netbeans but when i copy the content of "dist" folder somewhere else and execute jar it doesn't find the dependent nfile.nnet. So i need the way to make my application path portable. How to achieve this?

Solution thx to @RC and @Aaron Digulla from referenced post:
InputStream is=ClassLoader.class.getResourceAsStream("/nwork/nfile.nnet"); NeuralNetwork myNeuralNetwork = NeuralNetwork.load(is);

maljukan
  • 2,148
  • 2
  • 25
  • 35

1 Answers1

2

You can use resources. see Getting the inputstream from a classpath resource (XML file)

Community
  • 1
  • 1