- #1
pairofstrings
- 411
- 7
My teacher says : C language programs are portable on all platforms, which includes, Unix, Linux, windows etc.
My question : What is the difference between C language programs and Java language programs when all the programs of either languages can be run on any platforms?
My teacher says: C language .exe files cannot be run on all platform. They can only run on the platform where the program was originally developed and executed. But .c files can be run on any platforms. (I know it's not a good idea to spread my .c files to everyone). But in case of Java language programs .class files are given to JVM software which converts the byte code to machine code. And processor knows how to read machine code. So, these files which comes out of JVM can be run on any platform. All computers suppose to have JVM software if you want to run Java language program.
My question: So, if I want my .exe files to run on all platforms I need a software like JVM which makes .exe files run on any platform?
My teacher says: Yes.
My question is:
1. Suppose if I take a only .class file of Java from one computer with an intention that I want to run it on another computer. Then can I do it? If yes. Then does it matter what version of JVM I am using?
2. Why C language programs cannot be run on other platforms? Is it because of different hardware architecture of the computer that I want to run my C language program on or is it the Operating system issue?
3. I know that we need a JVM software for java programs to make the java programs run on all platforms but why do we need a JVM software at all? Is it because the internal hardware architecture of other computer is not compatible with the code or the Operating system of other computer that I want to run my java program on does not handle java program. Operating system issue?
I asked my teacher above questions but he just kept stressing on JVM software. And how C language don't have any such software.
Please answer.
My question : What is the difference between C language programs and Java language programs when all the programs of either languages can be run on any platforms?
My teacher says: C language .exe files cannot be run on all platform. They can only run on the platform where the program was originally developed and executed. But .c files can be run on any platforms. (I know it's not a good idea to spread my .c files to everyone). But in case of Java language programs .class files are given to JVM software which converts the byte code to machine code. And processor knows how to read machine code. So, these files which comes out of JVM can be run on any platform. All computers suppose to have JVM software if you want to run Java language program.
My question: So, if I want my .exe files to run on all platforms I need a software like JVM which makes .exe files run on any platform?
My teacher says: Yes.
My question is:
1. Suppose if I take a only .class file of Java from one computer with an intention that I want to run it on another computer. Then can I do it? If yes. Then does it matter what version of JVM I am using?
2. Why C language programs cannot be run on other platforms? Is it because of different hardware architecture of the computer that I want to run my C language program on or is it the Operating system issue?
3. I know that we need a JVM software for java programs to make the java programs run on all platforms but why do we need a JVM software at all? Is it because the internal hardware architecture of other computer is not compatible with the code or the Operating system of other computer that I want to run my java program on does not handle java program. Operating system issue?
I asked my teacher above questions but he just kept stressing on JVM software. And how C language don't have any such software.
Please answer.
Last edited: