Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

will my linux class files work on solaris  RSS feed

 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a small doubt, i create an application on a windows platform and compile on the same platform.

Do i need to compile my files on the linux or solaris platform if i port them to linux/solaris.Or can i use them as such.

How does the compilation work for different OS's/Platforms
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Certainly. That's one of the main benefits of Java. Your class files and Jars will work on any platform for which you have a JVM. Well, actually, that JVM has to be at least as new a version as the one on which you compiled, but the platform doesn't come into it.

Despite Java's claims to platform independence, a few things may not work when you move to the new platform. Some of your classes may have inadvertently made platform-specific assumptions (e.g. assuming the file separator is forward-slash). Also, a very small number of features of Java itself don't behave absolutely the same on different platforms.

That said, if you're just moving from Linux to Solaris, you should have no trouble at all, as they are so similar.
 
madhup narain
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I read that the compiler compiles object code that can be used for the same family of CPU(intel x6, sparc).

If i move from one family of processor to another then would i have to recompile my code ? thats one doubt that i have been having for quite some time.

Regards
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by madhup narain:
hi,
I read that the compiler compiles object code that can be used for the same family of CPU(intel x6, sparc).


You read wrong. As Peter says, a Java class file will run on a JVM on any machine: x86, Sparc, PowerPC, StrongARM, whatever.

What you say is true about other languages -- C, for example. Perhaps what you read was talking not about a Java compiler but about some other language's compiler.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!