How to Make a JAR File with Resources (Audio) - Java Extra 9

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 34

  • @chessdad182
    @chessdad182 Год назад

    Very helpful! Thanks!

  • @amarboparai4159
    @amarboparai4159 Год назад +4

    And if the getResource method doesn't work, try using "/" forward slash before file name. ex. ("/audio.wav"). That's how it worked for me.

  • @Code.J
    @Code.J 3 года назад

    Thank you so much! I've been trying to get audio to work via an executable jar, but I guess executable jars run much different than exporting as a normal jar.. You're a life saver

  • @treyjones545
    @treyjones545 4 года назад

    Thank you sir! I'm just starting out, and this is at least the second video of yours that has helped me with my project.

    • @RyiSnow
      @RyiSnow  4 года назад

      Glad I could help! Thank you for the comment!

  • @sparkster_aion
    @sparkster_aion 5 лет назад

    Worked like a charm! thanks a bunch

  • @huuthinh6122
    @huuthinh6122 2 года назад

    That exactly what i want ! Thank you

  • @neemiashd2289
    @neemiashd2289 8 дней назад

    thank u mate!

  • @dunayqudretli3382
    @dunayqudretli3382 3 года назад

    Thanks man you are angel!

  • @MvpMartell
    @MvpMartell 3 года назад +1

    Hello Ryi.
    So after watching it video like ten times, I followed everything I said perfectly. But when I run my program, an error message pops up saying: Java.lang.NullPointerException.
    It points at the clip.setFramePosition(0);
    And
    mu14.play( ); as the reason for not working.....my code is this...which I got from you....It's not letting me create a jar file with the audio
    public class Music {
    Clip clip;
    public void setURL(URL sound filename) {
    try {
    AudioInputStream sound = AudioSystem.getAudioInputStream(sound filename);
    clip = AudioSystem.getClip( );
    clip.open(sound);
    } catch (Exception e) {
    }
    }
    public void play( ) {
    clip.setFramePosition(0); //it points error at this line Ryi.
    clip.start( );
    }
    Public class Title screen handler implements Action Listener{
    public void actionPerformed (ActionEvent event) {
    String (your choice) {
    case "start":
    mu13.setURL(sound URL);
    mu13.play( ); //error points here too..
    start button.setVisible(false);
    mainMenuScreen("start");
    break;
    }
    }

    • @schoeyb
      @schoeyb Год назад

      did you manage to fix it dude? I'm having a similar issue when I try to export my game as a JAR

  • @ZeroHeroPlays
    @ZeroHeroPlays 7 лет назад +3

    Your awesome!!

  • @thornadotrigger3073
    @thornadotrigger3073 2 года назад

    I want to see a gun firing through sound effects.

  • @lrdrums98
    @lrdrums98 7 лет назад

    Very helpful, thanks very much for this.

    • @RyiSnow
      @RyiSnow  7 лет назад

      You're welcome!

  • @segelsonproduction
    @segelsonproduction 6 лет назад +1

    Thanks!

  • @antonioestevezgonzalez243
    @antonioestevezgonzalez243 2 года назад

    Hi. Could you please Help. I have exported one Jar File. In eclipse i have a Source Directory Named (Configuration). When i execute the application in Eclipse i can have access to the file located in /configuration/config.properties File propertieFile = new File(getClass().getClassLoader().getResource("configuration/config.properties").getFile()); Then i make a Test if(propertieFile.exists(){ System.out.println("exists");}
    My Problem is this works on Eclipse. but when i export my Project in .jar File and execute the Jar File it does not work anymore.
    How do i pass a new File to the File Class for checking is exists when the Project ist exported in Jar File? I have try with URL .toUri many things. I Walk aroud the Google and i dont find yet a solution. I need to check if this file exists in the Resource Folder named configuration and if not to have the chance to create the Properties File. Having a reference from File class.
    Very important i dont use Marven or Spring.
    Is really crazy sometimes the Project looks good in Eclipse and by exporting the Jar File the change the structure.
    You would help me really too much i you have a solution for this problem. i am studying Java and i dont want to give up.
    Thanks.

  • @potternubela6632
    @potternubela6632 4 года назад

    hey RyiSnow, will this code work if we move the jar file to another system or delete the audio from the res folder?? THANK YOU SO MUCH BTW!!!

    • @RyiSnow
      @RyiSnow  4 года назад +1

      Yes the jar file should work as long as you packed the audio file into the file and the targeted system has appropriate version of Java.

    • @potternubela6632
      @potternubela6632 4 года назад

      @@RyiSnow thank you so much for helping!

  • @mystudy7814
    @mystudy7814 2 года назад

    I am finding axactly. What you doin in this video
    So you use github ??

  • @williamcouroux2980
    @williamcouroux2980 7 лет назад

    hey i was using the sound effect video and implemented it into my RPG game, i came across a slight problem. When i want to make it so both the title screen button plays a sound effect and also take me to the next screen. do you know how this could be done

    • @williamcouroux2980
      @williamcouroux2980 7 лет назад

      Also if possible how can you adapt it to full screen?

    • @RyiSnow
      @RyiSnow  6 лет назад +1

      I'm not sure how you constructed your code but basically you can add
      se.setURL(clickSoundURL);
      se.play();
      to your actionPerformed method like this:
      public void actionPerformed(ActionEvent event){
      se.setURL(clickSoundURL);
      se.play();
      createGameScreen();
      }

    • @williamcouroux2980
      @williamcouroux2980 6 лет назад +4

      RyiSnow thank you so much, keep doing what you do, you are very good at demonstrating and explaining java. It has helped me so much!

    • @RyiSnow
      @RyiSnow  6 лет назад

      Glad to hear that!

  • @CHLOESYED732
    @CHLOESYED732 5 лет назад +1

    thanks a lot!

  • @alexanderreiner7694
    @alexanderreiner7694 3 года назад

    Hey, I try to recreate your stuff and was working on it for like 3h, can U please upload this code to some webside or send it to me?

  • @erikhemrick9541
    @erikhemrick9541 3 года назад

    Does anyone know how to do this in IntelliJ?

  • @kevinphan3142
    @kevinphan3142 4 года назад +1

    I love you

  • @KindaTiredIg
    @KindaTiredIg 3 года назад

    Ummm I had some code already I don't think I can change it.... Is it possible?? Here is the Pastebin pastebin.com/g09zBsrL