Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: I can not create an Executable .Jar File

  1. #1
    Member
    Join Date
    Sep 2013
    Posts
    41
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default I can not create an Executable .Jar File

    Hi, I finished my game, and I would like to "publish" it, however when I Export the project alongside the resource files, the jar file does not:
    1-Play the music
    2- Display Pictures
    3- Start the actual game.


    Untitled.png


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I can not create an Executable .Jar File

    You need to debug the code to see what the problems are.
    Open a command prompt window and enter the java command to start the execution:
    java -jar TheJarFileNameHere.jar

    That will allow you to see any error messages written to the console.

    Copy the full text of any error messages you want help with and paste it here.

    If there aren't any error messages, then some println() statements need to be added to the code so show what the code is doing and what the values of variables are.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Sep 2013
    Posts
    41
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: I can not create an Executable .Jar File

    The command prompt tells me it can not execute.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I can not create an Executable .Jar File

    Please copy the full contents of the command prompt window and paste it here.

    On Windows: To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Sep 2013
    Posts
    41
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: I can not create an Executable .Jar File

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\sakonpure6>java -jar HalfLife3.jar
    Error: Unable to access jarfile HalfLife3.jar

    C:\Users\sakonpure6>
    I placed the jar file on my desk top

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I can not create an Executable .Jar File

    Unable to access jarfile HalfLife3.jar
    The jar file must be in the same folder where the java command is executed. For the last post that would be:
    C:\Users\sakonpure6
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Sep 2013
    Posts
    41
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: I can not create an Executable .Jar File

    Thanks, this is what I got.

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\sakonpure6>java -jar HalfLife3.jar
    java.io.FileNotFoundException: Music\intro.wav (The system cannot find the file
    specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at com.sun.media.sound.WaveFloatFileReader.getAudioIn putStream(Unknown S
    ource)
    at javax.sound.sampled.AudioSystem.getAudioInputStrea m(Unknown Source)
    at Game.PlaySound$1.run(PlaySound.java:29)
    at java.lang.Thread.run(Unknown Source)
    java.io.FileNotFoundException: Music\RisenShine.wav (The system cannot find the
    file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at com.sun.media.sound.WaveFloatFileReader.getAudioIn putStream(Unknown S
    ource)
    at javax.sound.sampled.AudioSystem.getAudioInputStrea m(Unknown Source)
    at Game.PlaySound$1.run(PlaySound.java:29)
    at java.lang.Thread.run(Unknown Source)
    java.io.FileNotFoundException: Music\music.wav (The system cannot find the file
    specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at com.sun.media.sound.WaveFloatFileReader.getAudioIn putStream(Unknown S
    ource)
    at javax.sound.sampled.AudioSystem.getAudioInputStrea m(Unknown Source)
    at Game.PlaySound$1.run(PlaySound.java:29)
    at java.lang.Thread.run(Unknown Source)
    Error Loading Map.txt File.
    Exception in thread "Thread-6" java.lang.NullPointerException
    at Game.Map.readFile(Map.java:170)
    at Game.Map.<init>(Map.java:27)
    at Game.Board.<init>(Board.java:73)
    at Game.Main$3.run(Main.java:70)
    at java.lang.Thread.run(Unknown Source)

    C:\Users\sakonpure6>

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I can not create an Executable .Jar File

    java.io.FileNotFoundException: Music\intro.wav (The system cannot find the file
    specified)
    Is that file in the jar file? If so the code must treat it as a resource and use one of getResource methods to access it.
    If it can't be in the jar file, then the Music folder must be in the same directory as the jar file.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Member
    Join Date
    Sep 2013
    Posts
    41
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Re: I can not create an Executable .Jar File

    k thank you

Similar Threads

  1. How to make an executable .jar file?
    By bdennin in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 11th, 2013, 05:22 PM
  2. Cannot create executable jar file
    By viper_pranish in forum Java Theory & Questions
    Replies: 4
    Last Post: March 20th, 2013, 10:31 AM
  3. [SOLVED] Create an executable (.jar or .exe) using code
    By nosxlimit in forum Java Theory & Questions
    Replies: 6
    Last Post: May 31st, 2012, 11:55 PM
  4. [SOLVED] no sound from executable jar file
    By cl2606 in forum What's Wrong With My Code?
    Replies: 17
    Last Post: June 8th, 2011, 06:41 PM
  5. Jar Executable File
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 43
    Last Post: June 23rd, 2010, 03:53 PM