My question is on platform interdependency and portability of Java programs.
I have written a simple application using Java Swing (say its is a small product) and tested completely. Now i have to install this application in new Linux and new Windows OS. What are all the steps that i need to do for the application to work in new machines?
My questions are:
1. Do i need to change code for Linux and Windows?
2. Do i need to install JVM / JDK / JRE in new machines? If then, Is the JVM / JDK / JRE is different for Linux and Windows?
3. Application has 60 Java files. How do i package the application?
4. I don't want to transfer the source code (.java files) to new machines. Even decompilation should not be allowed. How can i achieve that?
1. No, you don't need to change the code - you do not even have to recompile it. Java class files are portable across platforms. Ofcourse, as Campbell said, if you have used platform-specific constructs in your code, then you might get trouble on other platforms.
2. Yes, you need a JRE. The JVM / JRE /JDK is different for different operating systems, but that doesn't matter for your Java program.
4. There is no need to distribute source (.java) files. As said at point 1, your compiled code should just run on any platform for which there is a JRE. The only way to prevent people from decompiling the code is to not give them the code - instead of making it a stand-alone desktop program, make it a program on the web, with the code running on your server, instead of the client's computer. If you don't want that, you can use an obfuscator to make your code harder to decompile, but it won't be completely impossible to prevent it.