Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Platform interdependency and portability of Java programs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Platform interdependency and portability of Java programs" Watch "Platform interdependency and portability of Java programs" New topic
Author

Platform interdependency and portability of Java programs

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Dear All,

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?

Thanks
Mathews.







Thanks,
Mathews
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37958
    
  22
Mathews P Srampikal wrote:Dear All, . . .
1. Do i need to change code for Linux and Windows?
As long as you have avoided platform-sensitive code like \\ for path separator or \n for line end, no.

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?
Yes. Yes. You want a JRE.

3. Application has 60 Java files. How do i package the application?
Like this?

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?
By keeping the entire code on your machine and exporting the application as a web service. It is easy to deploy .class files only, but they can be decompiled.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Platform interdependency and portability of Java programs
 
Similar Threads
jvm
IS 1.6 JRE Required
basic java
JVM,JRE & PORTABILITY
Disadvantages of Java