• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why i needed to recomplie ??

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Ranchers,I am happy to be here again.Here is the problem, I was compliling and running my programs under Windows,now that I shifted to linux,. I put all the programs in a pin drive and copied them to some folder in linux.To my surprise ! I was not able to run a single program without re-compiling,but doesn't java support "compile once run any where"
I was thinking if the .class file is present, then the program will work without any troubles.Anyway, now that being my question,I would appreciate your comments my dear friends.
Ammar Salem
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happened when you tried to run them without recompiling ?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai ammar,

your compiling java file in windows .and try to run in linux.

it will run and it should run utill you specified some property(os related)in that file.

whether you configured class path in linux properly?

without proper reason ,please avoid the negative comments on java

thanks & regards,
seetharaman scjp 1.4
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, yes, your .class files are portable from one machine to another. But most major releases of Java define a new class file version, and so the class files created by default by a newer compiler will not necessarily run on an older JVM. For example, if your Windows machine has the current version of Java, JDK 1.6, and the Linux machine has a JDK 1.5 or older, then you'd have this problem.

You can tell a newer compiler to emit older format class files using the "-source" and "-target" switches; for example

javac -source 1.5 -target 1.5 Foo.java

will create Foo.class that will work on JDK 1.5 and JDK 1.6.
 
reply
    Bookmark Topic Watch Topic
  • New Topic