Question: Hello I am new at c# and I am doing a small game that I need to play mp3 files.

I've been searching about this and using wmp to do it, like this:

```
    WindowsMediaPlayer myplayer = new WindowsMediaPlayer();
    myplayer.URL = @"c:\somefolder\project\music.mp3";
    myplayer.controls.play();

```

I am able to play the file successfully with the full path of the mp3 file. The problem is that I can't find a way to use the file directly from the project folder, I mean, if I copy the project to another computer the path of the mp3 file will be invalid and no sound will be played. I feel that I am at a dead end now, so if someone can help me I would appreciate it! Thanks in advance

Answer: 
I think that your problem is the way you use `getResource()` :

```
Paths.get(getClass().getResource(filepath).toURI());

```

You use a relative classpath (that is relative to the the current class location) to retrieve the `"extrapack-renew.sql"` file.  

It means that this resource has to be located inside this path in your jar to be retrieved.  

If the resource is not located inside the current class path, the path used to retrieve the resource should start with a `"/"` character in order to specify an absolute name of the resource:

```
Paths.get(getClass().getResource("/"+filepath).toURI());

```

Of course if you use maven, `extrapack-renew.sql` should be in

the `src/main/resources/secure` folder of the source project so that `"/secure/extrapack-renew.sql"` be a resource in the classpath.
My solution was to have the properties files NOT in the jar archive, contrary to what was asked in the original title of the question.

I got it working, with a properties file sitting in the project home directory.

```
$ ll
total 52K
-rw-rw-r-- 1 stephane   10 févr. 13 10:49 application.properties
-rw-r--r-- 1 stephane 6,1K févr. 10 17:22 pom.xml

```

I can open this file and load its properties with:

```
properties.load(new FileInputStream(new File(DB_AUTOSELF_PROPERTIES_FILENAME)));

```

Then I can move the `.jar` archive and the properties file to another directory, and run the application:

```
$ pwd
/home/stephane/trash
$ cp ~/dev/java/projects/AS/target/script-jar-with-dependencies.jar .
$ cp ~/dev/java/projects/AS/application.properties .
$ vi application.properties 
-rw-rw-r-- 1 stephane 10 févr. 13 10:53 application.properties
java -jar script-jar-with-dependencies.jar 1 2016-12-01 2017-02-12 all

```

My `pom.xml` file contains the plugins to copy the resources and create a fat `jar` archive:

```
  <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
      <execution>
        <id>copy-resources</id>
        <phase>validate</phase>
        <goals>
          <goal>copy-resources</goal>
        </goals>
        <configuration>
          <outputDirectory>${basedir}/target</outputDirectory>
          <resources>
            <resource>
              <directory>src/main/resources</directory>
              <filtering>true</filtering>
            </resource>
          </resources>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
      <archive>
        <manifest>
          <addClasspath>true</addClasspath>
          <mainClass>com.fatec.migration.script.utils.Script</mainClass>
        </manifest>
      </archive>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>assemble-all</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

```