ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
but when i compile my program on xp or fedora8 it worked only on xp and fedora8 but not mac
also i tried it on an older xp machine and it didn't work
when i compiled it on mac it worked on mac and xp but didn't try it on older xp yet
this seems to be a issue with some version number
only thing i saw was maybe multiple jre's installed or compiled with different versions ???
i dunno
it is kinda lame ... i thought java worked anywhere but i had to do a little work to make this so
i had to get my hands on a mac and compile code there then when i made jar file it seems to work everywhere
also when i try to double click my executable jar file in linux
fedora 8
it seems to treat it just like a archive file like a zip
why didn't it run the program
and how would i make it an application for linux
and why does it only seems to be platform independant when complied w/ mac
on all your machines. Java is mostly backwards compatible, but not forwards. If you compile some source with a Java 6 compiler, it won't run on a Java 5 runtime.
when i can get to them i will
just a little lame - this issue is mucking up one of the beauties of the language
java -version = 1.6.0_03 on this xp laptop
i downloaded it not too long ago and on fedora8 i used whatever comes with eclipse on the install dvd
as far as my families mac's ... hell i dunno whatever comes with them
my dads is new and mom and sisters are older
i assume this laptop is newer than most if not all of the other machines so i don't get it ... i guess that word MOSTLY backwards compatible is the key
why would 6 not run on 5 ... isn't that what backwards compatible means
ok but would that be equal to compiling with that version
or does that make it backwards compatable
like ... do i lose the ability to now run with the newer version i have
say i run this from my xp laptop that has 1.6 i guess
javac -target 1.4 Program.java
then will it run only on 1.4 or will it work on 1.6 and 1.4
know what i am asking . . .
wait i think i get it
it needs to be compiled w/ oldest version to work on them all
if compiled w/ 1.6 it will only work for 1.6
if compiled with 1.5 it will work for 1.5 and 1.6 machines
if compiled on 1.6 with 1.4 -target switch it will work w/ 1.4 and greater
1. You seem to think double-clicking on a .jar should run it as a program
Granted, that might be convenient in some cases. It might be downright annoying in other cases. What if you need multiple .jars? What if you have multiple different "main()" entries? What if you just want to look at the contents of a resource .jar? What if it's malicious? Etc etc ad nauseum...
Bottom line: nobody says it has to work this way; and, more often than not, it simply *doesn't*.
2. You are correct: your Java Runtime must be greater than or equal to the Java version that the .class files in the .jar were compiled under.
There are many ways to achieve this.
For example, you can make sure the latest/greatest runtime is loaded. You can install *multiple* runtimes (and switch between them with a simple environment setting, like $JAVA_HOME, or changing your -classpath). Or you can explicitly tell a new compiler to write .class files compatible with an older version (e.g. -target).
what do you recommend then
java doesn't compile into any executable format
executable jar seems the best
all you have to do it double click and it runs the program
just run jar xvf filename.jar to extract it
my dads mac has this cool xcode developer tools that can make .app files from java files
seen things like this for windows but they seem to cost money
i made a sudoku game for my grandma and this seems to be the best way to give it to her ... all she has to do it get one file and double click it
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.