This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Strange Problem in Running Jar!  RSS feed

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I had developed a Project in Eclipse in Windows. I have created the jar file and i have uploaded it in a Unix machine using Filezilla. Now when i run the jar on the Unix machine, I get an error message as:



Could you please tell me the how to get rid of this problem! I have JAVA 1.6 installed on my windows machine and the java installed in the Unix box is 1.4.
 
Sheriff
Posts: 21462
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can either use the "-source 1.4 -target 1.4" compiler flags, or upgrade the JVM on your Unix box.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message means that you have compiled your classes with JDK version 6, but that you are trying to run the classes on an older JRE (Java 5 or older).

Java is downwards compatible - classes compiled with an older version run unmodified on a newer version, but not upwards compatible - classes compiled with a newer version do not run on an older version.

Make sure you compile your source code with the right JDK version. JDK 1.4 is still available for download on Sun's website.

You could use the -source and -target switches as Rob suggests, but if you use classes from the Java 6 standard API which don't exist in the older JRE, it will still not work correctly.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me the syntax of the command. Because the source compiler is in a Windows machine and the target compiler is in a Unix box!

JDK 1.5 is installed in a folder called /software/j2sdk1.5.0_10 in the UNIX box.

I tried running the command using command:

java -jar FTPDownloadClient_fat.jar
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They *did* tell you the syntax of the command. You've compiled under 1.6, but are running under 1.5.
 
Rob Spoor
Sheriff
Posts: 21462
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source and target must be set when compiling, not when running the JVM. So it's "javac -source 1.4 -target 1.4 <anything else you want>". If you're using an IDE like Eclipse you can specify the target platform in the project properties.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone. I changed the compiler to 1.5 in Eclipse and created the jar again! Now its working!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!