Results 1 to 12 of 12
  1. #1
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Question Creating a movable .jar...super annoying :/

    I am trying to create a jar file of the program I have written. It is finally completed and ready to be transferred to my dad's shop computer. The only problem is, when I create the jar it works just fine on my computer, but if I transfer it to any other machine it says it cannot find the main class. I have even copied the .class file into the same folder as the jar on the other machine and it still doesn't find it. PLEASE HELP! This has been frustrating me for days! :O

    Thanks!!

    - Tombomb

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,040
    Rep Power
    10

    Default Re: Creating a movable .jar...super annoying :/

    How are you creating your jar? What is in the manifest file? How are you trying to run your jar?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: Creating a movable .jar...super annoying :/

    Oh sorry I left a lot out. I am creating it with Eclipse, and it just says "Create manifest file", so I'm not sure whats in it or how to edit it, and I'm running it by double clicking the icon. And that's how I want to be able to run it on any PC.

    Edit: I have also tried playing with opening the .jar on the new machine and editing the manifest file in the archive...so I guess I found how to edit it but it only consists of these lines:

    Manifest-Version: 1.0
    Class-Path: .
    Main-Class: TestFileIO

    and I don't know if these are significant or not but, I am getting burnt out playing with this, any help would be extremely appreciated.
    Last edited by Tombomb; 01-31-2012 at 12:36 AM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Creating a movable .jar...super annoying :/

    Can you try and run it from the shop PC in a terminal?
    java -jar <yourjarfile>.jar
    and see if it works? If not can you try the same thing from your machine, ensuring the jar file is nowhere near where you built it (in case it's pulling in stuff from your workspace).

  5. #5
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: Creating a movable .jar...super annoying :/

    I can do it from my machine with the cmd ONLY IF I rename the file to a one word name, otherwise it says it is unable to access it. Would this make a difference for other PC's? I will try it on the other PC in a while, I have to go to class right now, I'll check back in about an hour and a half. Also, it is very possible it is pulling more than it should from my workspace, I'm not 100% sure how to organize using Eclipse yet, its huge and I recently started using it.

    Thanks!

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Creating a movable .jar...super annoying :/

    I can do it from my machine with the cmd ONLY IF I rename the file to a one word name
    If a parameter contains a space, the entire parameter needs to be enclosed in double quotes. That has everything to do with how the command prompt handles command strings and nothing to do with Java.

    How else would the command interpreter determine whether you want to pass one parameter containing a space, or two separate parameters?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: Creating a movable .jar...super annoying :/

    Okay, but what needs to be done to get the java command to be a valid cmd statement? I have been playing with environment variables for a day now on the other computer and its just not working.. :/ I'm staining once that gets setup that I will be able to just click the jar to run it?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Creating a movable .jar...super annoying :/

    So:
    java -jar <yourjar>.jar
    gives a "'java' is not a recognized command" error on the shop PC?

    Does that PC have a JRE installed?

  9. #9
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: Creating a movable .jar...super annoying :/

    To my knowledge, yes. It has java on it, and it has an environment variable "Java" that points to the bin of jre6, and it still has the error. I am completely confused as to how to get this to work because as I understand it, it already should.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Creating a movable .jar...super annoying :/

    Is the folder containing java.exe included in the PATH?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Creating a movable .jar...super annoying :/

    I'd try and reinstall it myself.
    Sounds like some of the mappings have gone walkabout.

  12. #12
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: Creating a movable .jar...super annoying :/

    I actually got it to work after four hours with my professor. It turned out to be version issues of java with the two computers and my code. Thanks for all the replies! They are appreciated!

Similar Threads

  1. Drawing in Java? or Maybe movable buttons?
    By Bagzli in forum Advanced Java
    Replies: 7
    Last Post: 06-29-2011, 12:57 PM
  2. Annoying Popups
    By camickr in forum Suggestions & Feedback
    Replies: 24
    Last Post: 03-01-2011, 04:58 PM
  3. calling variable using super super..
    By Stephen Douglas in forum New To Java
    Replies: 7
    Last Post: 08-16-2010, 07:12 AM
  4. JToolBar movable but not floatable
    By Fosters in forum AWT / Swing
    Replies: 0
    Last Post: 08-22-2008, 04:04 PM
  5. movable image with buttons
    By boytjie in forum NetBeans
    Replies: 0
    Last Post: 04-18-2008, 01:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •