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
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?
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.
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).
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!
Re: Creating a movable .jar...super annoying :/
Quote:
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
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?
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?
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.
Re: Creating a movable .jar...super annoying :/
Is the folder containing java.exe included in the PATH?
db
Re: Creating a movable .jar...super annoying :/
I'd try and reinstall it myself.
Sounds like some of the mappings have gone walkabout.
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!