• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Strange Problem in Running Jar!

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone. I changed the compiler to 1.5 in Eclipse and created the jar again! Now its working!
 
Goodbye moon men. Hello tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic