views:

130

answers:

6
+4  Q: 

java compilation

Hi, i am not a java developer so is it possible for me to develop java code on windows and then deploy the windows compiled .class files to a solaris server...would it run..

+5  A: 

Yes, that is specifically the premise behind Java's Write Once Run Anywhere motto

Kevin
+2  A: 

Yes, java byte code (class files) is platform independent.

tangens
+2  A: 

Yes, 99.9% of the time this is the case. There are some hiccups with non-Sun (read, IBM) JVMs that aren't perfectly cross-platform compatible.

Michael Krauklis
Can you give an example? The only time I saw anything like this is when our code made assumptions about API calls that weren't specified in the documentation.
Joachim Sauer
Sorry, I don't have a concrete example on hand. My experience with this is 6+ years old, but I do remember we were stuck for quite some time on JRE 1.3.1 due to IBM JVM compatibility issues with a third party vendor's product. I wish I could be more specific but it's been a while.
Michael Krauklis
Ok, fair enough. But "IBM JVM compatibility issues with a third party vendor's product" sounds as if it could also be the third party vendor that depends on un-specified behaviour (the same mistake I made back then).
Joachim Sauer
I've worked with cross platform (Sun Linux, Sun Windows, Sun SunOS, IBM AIX, IBM Linux, HP-UX, and old Digital Alpha) JVMs and have had no problems with the server (multi-threaded custom application server, with CORBA to boot) and never had any problems from 1.3 and on. Well, except the cases where my code did not fully adhere to the API specifications and on some OS's (HP-UX) the vendor took advantage of the allowed latitude - that is my code had a bug so it worked in some VMs but not others, and I was able to fix it by properly applying the API contracts.
Kevin Brock
+5  A: 

Yes, it should.

However, watch out for the most common pitfalls like:

  • version incompatibility (e.g. class file version, runtime environment)
  • system dependent resource descriptors (e.g. file paths)
Dieter
I guess it's along the lines of the above comments but make sure you have all the classes and the correct classpaths.
Ben
+1  A: 

as the others already said, it will most likely work. Id suggest you read some info on the Java Virtual Machine as this wonderful virtual device allows running java byte code on (nearly) any machine...

CatholicEvangelist
A: 

In general, It should. Mind it that class file don't run by themselves, you need to have java installed on the machine. It should also be compatible version.

fastcodejava