![]() |
|
[Java] Cant play mp3 files using absolute path (after building executable jar) - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Cant play mp3 files using absolute path (after building executable jar) (/showthread.php?tid=5694556) |
Cant play mp3 files using absolute path (after building executable jar) - Account of the Gods - Aug 14, 2017 Code C:\Windows\system32>java -jar C:\\Stickmen.jarI used some workaround but that would cause just more errors. Whats your way to handle it? * - GenericSkid - Aug 14, 2017 Not a solution but, ehy are you storing your audio in System32? That seems like a really odd place to be doing things, plus for file IO it requires higher privileges. Why not store the audio relative to your application? * - Mohinder - Aug 15, 2017 You might want to store your files on a more solid place. You could create a folder in the user.home directory and create a path to that. If you use Code System.getProperty("user.home") + "\" + folderName + "\menuSound.mp3"* - Account of the Gods - Aug 15, 2017 (Aug 14, 2017 02:41 PM)Lord Pankake Wrote: Not a solution but, ehy are you storing your audio in System32? That seems like a really odd place to be doing things, plus for file IO it requires higher privileges. Why not store the audio relative to your application? nonono. It stores it there automatically. I have mp3 file in "default package" and instead of path I have "file.mp3" - it works from IDE but when i run it from .JAR then it reads system32/file.mp3 or system32/game.jar!/file.mp3 (notice the weird "!") (Aug 15, 2017 12:30 AM)Mohinder Wrote: You might want to store your files on a more solid place. You could create a folder in the user.home directory and create a path to that. Is there a way to run it from the JAR im providing to the user? instead of messing with his local files. im not creating a hack. * - GenericSkid - Aug 15, 2017 (Aug 15, 2017 02:09 AM)foreignseo Wrote: nonono. It stores it there automatically. I have mp3 file in "default package" and instead of path I have "file.mp3" - it works from IDE but when i run it from .JAR then it reads system32/file.mp3 or system32/game.jar!/file.mp3 (notice the weird "!") Do you mean it's checking that location, or it actually does put things in there? Either way that's exceptionally odd unless you're specifically telling your program to use "system32" as your "user.home" (basically, the execution directory). Would you mind posting some code? It could just be a case of mis-handling paths. (Aug 15, 2017 02:09 AM)foreignseo Wrote: Is there a way to run it from the JAR im providing to the user? instead of messing with his local files. im not creating a hack. Use Class.getResourceAsStream. PHP Code * - MindOfLogic - Aug 15, 2017 You might not have permission to your system32 directory from eclipse? * - Mohinder - Aug 15, 2017 (Aug 15, 2017 02:09 AM)foreignseo Wrote: nonono. It stores it there automatically. I have mp3 file in "default package" and instead of path I have "file.mp3" - it works from IDE but when i run it from .JAR then it reads system32/file.mp3 or system32/game.jar!/file.mp3 (notice the weird "!") Im not saying this is a hack or something. You can copy your files to a folder you create in the user.home directory. From there you can run it, or just use the resources out of your jar file. |