Has every program that is installed a default complier with itself? - java

I am not native English user and I am sorry for bad English but very interested in programming.
My question is: Has every program that is installed on a specific OS a separate compiler or all programs that are installed on that OS use from a default OS compiler?
Thanks.

Your question is marked with 'java'. Regarding Java
you must have JRE to run a java program. JRE stands for java runtime environment, which includes JVM (java virtual machine) and another runtime units. Java feature is to have single JRE to run every java program (let alone versions etc). JRE will execute java program.
if you want to create a java program on your computer, you should have have Java SDK (software development kit). It includes compiter and huge bunch af another necessary and useful tools. SDK can turn your java source code to an executable java program.

If the question is general, like, what happens when you install a desktop app, it depends of a app type and it's installer type.
There are some, that are distributed with sources and are to be compiled at the installation phase right at your machine. Most often they have anything they need to run the installation successfully, including all necessary compilters. In vast majority of cases you are not supposed to have something preinstalled on you OS prior to the program installation.
But mainly a program is distributed as a bundle of binary artifacts. They are already compiled and packed and are delived in this state. So no, here you are not expected to have a compiler on you machine.

Related

Installing Java for Mac?

I have a Macbook Pro running El Capitan (10.11.6). It doesn't come with Java and the advise I heard is to not install it because it's unsafe (and apparently Oracle bundles the installation with some ask bar tool or adware so I don't want that).
However, is there a way to code in Java without that? When I try to run Java programs from terminal (java foo.java), it tells me I need it. Is it just the browser plugin that's unsafe or should I keep it away from my computer entirely?
You can't, Java programs run in a virtual machine that you need to install (by installing the Java Runtime Environment).
You shouldn't run into any risks just by installing Java in and of itself, as long as you run programs that you know you can trust. If you really want to feel safe, disable the Java plugin from your browser (Actually, I checked and my broswer doesn't have any Java plugin installed, so you don't even need to do that). The toolbar is completely optional, just uncheck the option during installation.
If you want to write Java code you'll have to install the Java SDK too.

How to install java7 version to Run an applet in web broswer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am running an applet program in my browser.When i am running that applet the browser is asking to me install java7.And then i am redirecting to THIS LINK.When i download java and install the applet is working fine.When i install i got only jre only.I did not get jdk.
My Question is:
I heard one thing previously.Browser contains java.So if it is correct ,Why i need to install java7 in my system.Only browser need java7 version.Is there any possibility to install in browser only.
Thanks in advance...
JRE includes browser plugins for Applet execution. You only need java runtime to run your applet. JDK is development kit(which BTW includes JRE) but you don't need it in your case.
For Applet's Execution Environment read corresponding java docs.
It says
An applet will run in an existing JRE if the following conditions are met:
The JRE version required by the applet matches an existing JRE.
The JRE's startup parameters satisfy the applet's requirements.
So all you need is correct JRE version to run your applet.
No, that's not correct. They require a JRE installed on the OS and a plug-in in the browser to glue them together.
Many years ago (Windows 95?) Windows included a JRE by default, so there was no need to install Java. Perhaps from here the confusion, but these times are long gone.
Java Runtime Environment
Java Runtime Environment contains JVM, class libraries, and other supporting files.
It does not contain any development tools such as compiler, debugger,
etc. Actually JVM runs the program, and it uses the class libraries,
and other supporting files provided in JRE. If you want to run any
java program, you need to have JRE installed in the system
The Java Virtual Machine provides a platform-independent way of executing code; programmers can concentrate on writing software, without having to be concerned with how or where it will run.
If u just want to run applets (ex: Online Yahoo games or puzzles), JRE
needs to be installed on the machine. JVM (Java Virtual Machine)
JDK (Java Development Kit)
Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
You need JDK, if at all you want to write your own programs, and to
compile the m. For running java programs, JRE is sufficient.
JRE is targeted for execution of Java files
i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.
JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file
JRE (Java Runtime Environment)

What is the difference between JVM, JDK, JRE & OpenJDK?

What is the difference between JVM, JDK, JRE & OpenJDK?
I was programming in Java and I encountered these phrases, what are the differences among them?
JVM
The Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn't understand Java source code; that's why you need compile your *.java files to obtain *.class files that contain the bytecodes understood by the JVM. It's also the entity that allows Java to be a "portable language" (write once, run anywhere). Indeed, there are specific implementations of the JVM for different systems (Windows, Linux, macOS, see the Wikipedia list), the aim is that with the same bytecodes they all give the same results.
JDK and JRE
To explain the difference between JDK and JRE, the best is to read the Oracle documentation and consult the diagram:
Java Runtime Environment (JRE)
The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. In addition, two key deployment technologies are part of the JRE: Java Plug-in, which enables applets to run in popular browsers; and Java Web Start, which deploys standalone applications over a network. It is also the foundation for the technologies in the Java 2 Platform, Enterprise Edition (J2EE) for enterprise software development and deployment. The JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications.
Java Development Kit (JDK)
The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.
Note that Oracle is not the only one to provide JDKs.
OpenJDK
OpenJDK is an open-source implementation of the JDK and the base for the Oracle JDK. There is almost no difference between the Oracle JDK and the OpenJDK.
The differences are stated in this blog:
Q: What is the difference between the source code found in the OpenJDK repository, and the code you use to build the Oracle JDK?
A: It is very close - our build process for Oracle JDK releases builds on OpenJDK 7 by adding just a couple of pieces, like the deployment code, which includes Oracle's implementation of the Java Plugin and Java WebStart, as well as some closed source third party components like a graphics rasterizer, some open source third party components, like Rhino, and a few bits and pieces here and there, like additional documentation or third party fonts. Moving forward, our intent is to open source all pieces of the Oracle JDK except those that we consider commercial features such as JRockit Mission Control (not yet available in Oracle JDK), and replace encumbered third party components with open source alternatives to achieve closer parity between the code bases.
Update for JDK 11
An article from Donald Smith try to disambiguate the difference between Oracle JDK and Oracle's OpenJDK : https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later
As mentioned in comments by #Alan Evangelista, Java Web Start has been deprecated by Oracle in Java SE 9 and removed in Java SE 11.
JVM is the Java Virtual Machine – it actually runs Java ByteCode.
JRE is the Java Runtime Environment – it contains a JVM, among other things, and is what you need to run a Java program.
JDK is the Java Development Kit – it is the JRE, but with javac (which is what you need to compile Java source code) and other programming tools added.
OpenJDK is a specific JDK implementation.
JDK (Java Development Kit)
Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
You need JDK, if at all you want to write your own programs, and to compile them. For running java programs, JRE is sufficient.
JRE is targeted for execution of Java files
i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.
JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file.
JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system
The Java Virtual Machine provides a platform-independent way of executing code;
That mean compile once in any machine and run it any where(any machine).
JVM (Java Virtual Machine)
As we all aware when we compile a Java file, output is not an ‘exe’ but it’s a ‘.class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.
The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.
There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.
A Java virtual machine (JVM) is a virtual machine that can execute Java ByteCode. It is the code execution component of the Java software platform.
The Java Development Kit (JDK) is an Oracle Corporation product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java Software Development Kit (SDK).
Java Runtime Environment, is also referred to as the Java Runtime, Runtime Environment
OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GPL) with a linking exception.
JVM is the virtual machine Java code executes on
JRE is the environment (standard libraries and JVM) required to run Java applications
JDK is the JRE with developer tools and documentations
OpenJDK is an open-source version of the JDK, unlike the common JDK owned by Oracle
JDK (Java Development Kit) :
contains tools needed to develop the Java programs.
You need JDK, if at all you want to write your own programs, and to compile them.
JDK is mainly targeted for java development.
JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries, and other supporting files.
JRE is targeted for execution of Java files.
JVM (Java Virtual Machine)
The JVM interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… Java Virtual Machine provides a platform-independent way of executing code.
JDK - Compiles java to ByteCode. Consists of debuggers, Compilers etc.
javac file.java // Is executed using JDK
JVM - Executes the byte code. JVM is the one which makes java platform independent. But JVM varies for platforms.
JRE - JVM along with java runtime libraries to execute java programs.
JVM : A specification which describes the the way/resources to run a java program. Actually executes the byte code and make java platform independent. In doing so, it is different for different platform. JVM for windows cannot work as JVM for UNIX.
JRE : Implementation of JVM. (JVM + run time libraries)
JDK : JRE + java compiler and other essential tools to build a java program from scratch
Another aspect worth mentioning:
JDK (java development kit)
You will need it for development purposes like the name suggests.
For example: a software company will have JDK install in their computer because they will need to develop new software which involves compiling and running their Java programs as well.
So we can say that JDK = JRE + JVM.
JRE (java run-time environment)
It's needed to run Java programs. You can't compile Java programs with it .
For example: a regular computer user who wants to run some online games then will need JRE in his system to run Java programs.
JVM (java virtual machine)
As you might know it run the bytecodes. It make Java platform independent because it executes the .class file which you get after you compile the Java program regardless of whether you compile it on Windows, Mac or Linux.
Open JDK
Well, like I said above. Now JDK is made by different company, one of them which happens to be an open source and free for public use is OpenJDK, while some others are Oracle Corporation's JRockit JDK or IBM JDK.
However they all might appear the same to general user.
Conclusion
If you are a Java programmer you will need JDK in your system and this package will include JRE and JVM as well but if you are normal user who like to play online games then you will only need JRE and this package will not have JDK in it.
In other words JDK is grandfather JRE is father and JVM is their son.
Developers develop using JDK, and first we write .java source code
Developers debug the code and compile the code into .class bytecode executable files in JRE
The executable files are executed by JVM, translating the bytecode into native machine code which machines can execute
Here is they relations:
Reference:
Java JDK, JRE and JVM
Java is the language and includes a strict and strongly typed syntax.
Java 2 Platform, Standard Edition, also known as J2SE, referred to the platform and included the classes in the java.lang and java.io packages, among others. It was the building block that Java applications were built upon.
A Java Virtual Machine, or JVM, is a software virtual machine that runs compiled Java code. Because compiled Java code is merely bytecode, the JVM is responsible for compiling that bytecode to machine code before running it. (This is often called the Just In Time Compiler or JIT Compiler.) The JVM also takes care of memory management so that application code doesn’t have to.
The Java Development Kit, or JDK, was and remains the piece of software Java developers use to create Java applications. It contains a Java language compiler, a documentation generator, tools for working with native code, and (typically) the Java source code for the platform to enable debugging platform classes.
The Java Runtime Environment, or JRE, was and remains the piece of software end users download to run compiled Java applications. It includes a JVM but does not contain any of the development tools bundled in the JDK. The JDK, however, does contain a JRE.
JVM : this actually means the byte code interpreter .It is platform dependent. For eg: in Windows platform the 'java.exe' or 'javaw.exe' precess is the jvm process.
JDK : is a toolkit containing necessary libraries and utilities to develop and execute java program/application
JRE: is the execution environment for a java application.ie, it only support runtime dependencies including jvm for compiled program. If we want to compile a java program we need jdk.
JVM : virtual machine of java. tells machine what to do with the Java Code. You cannot download JVM as is. It comes packaged in some other component.
JRE: Some other component referred as above is the JRE.
It is JVM+ other jars to create runtime environmeny
JDK: contains JRE(which in turn contains JVM). Once you get JDK you need not install JRE and JVM separately. It contains compiler which compiles your .java files to .class files
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms.
JRE
JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at runtime.
JDK
JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.
Link :- http://www.javatpoint.com/difference-between-jdk-jre-and-jvm
In summary:
JRE = JVM + Java Packages (like util, math, lang, awt, swing etc) +
runtime libraries
JDK = JRE + Development/debugging tools
If you want to develop in java, you need the JDK, but if you just want run java, you need the JRE.
Simple image to illustrate JDK, JRE, JDK.
JDK In general this will be installed only in development setups like in developers, QA systems in real-time at corporate companies. Original code which is running in servers will not have JDK.
JRE is a part of JDK and independently too installable in servers. In real-time servers which serving user requests will have only JRE installed and code developed by developers (in *.class format)
JVM Developer developed code > tested and executed in development machines. Execution phase require a medium for Java.
.class files are not native code (code which understands by cpu). To achieve WORA (Write Once Run Anywhere) concept can't be achieved if .java file is directly converted to native code.
Native code differs from OS to OS. So, Java created a intermediate file called .class and magical program called "JVM". Its JVM's duty to convert .class into native code.
JVM Java Virtual Machine , actually executes the java bytecode.
It is the execution block on the JAVA platform. It converts the bytecode to the machine code.
JRE Java Runtime Environment , provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.
JDK Java Development Kit, it has all the tools to develop your application software. It is as JRE+JVM
Open JDK is a free and open source implementation of the Java Platform.
In layman terms:- JDK = JRE + Development/debugging tools, where JDK is our complete package to work with Java, from creating compiling till running it.On the other hand JRE is just of running of code(Byte Code).
Note:- Whether we are installing JDK or JRE, JVM would come bundled with both the packages and JVM is the part where JIT compiler converts the byte code into the machine specific code.
Just read the article on JDK,JRE ,JVM and JIT
JDK: The complete package which you need to write and run java code
OpenJDK: An independent implementation of JDK for making it much better
JVM: Converts Java code into bytecode and provides the specifications which tells how should a Java code be compiled, loaded, verified, checked for errors and executed.
JRE: Implementation of the JVM with which some Java libraries are used to Run the program
JRE executes the application but JVM reads the instructions line by line so it's interpreter.
JDK=JRE+Development Tools
JRE=JVM+Library Classes
JVM is abbreviated as Java Virtual Machine, JVM is the main component of java architecture. JVM is written in C programming language. Java compiler produce the byte code for JVM. JVM reading the byte code verifying the byte code and linking the code with the ibrary.
JRE is abbreviated as Java Runtime Environment. it is provide environment at runtime. It is physically exist. It contain JVM + set of libraries(jar) +other files.
JDK is abbreviated as Java Development Kit . it is develop java applications. And also Debugging and monitoring java applications . JDK contain JRE +development tools(javac,java)
OpenJDK OpenJDK is an open source version of sun JDK. Oracle JDK is Sun's official JDK.
JDK - Tools like javac used to compile *.java files to *.class bytecode files (basically develop Java programs)
JRE - Tools to run *.jar files (basically run Java programs)
JVM - Tools to compile *.class files to executable machine code (run all Java bytecode)
OpenJDK is just a distribution of the Java JDK.

32/64 bit eclipse

On 64-bit openSUSE Linux, can a 32-bit eclipse running with 32-bit JVM compile code for a 64-bit system?
Is this setup possible? (Installing and running eclipse/java 32-bit on a 64-bit system)
If you're building pure Java, there's no such thing as compiling for a particular architecture - Java bytecode is portable across CPU architectures and 32/64-bitness.
If you want to compile another language (such as C++) then it gets a bit harder. Likewise you may find problems if you try to build JNI wrappers for one architecture on another.
When you compile in Java there is no notions of 32/64bits it's just java Bytecode. So yes, you can compile java in a 32bits environment and run it in a 64bits one.
The compiled Java program is always identical as Java runs through the Java virtual machine which handles the architecture and native calls. A Java program is not fully compiled all the way to machine code, only up to bytecode for the virtual machine. This means that a Java program can work on any architecture.
The crucial point is the JVM you choose to run Eclipse iwth and your final program.
If all your code is Java then the result can run on either. The most visible difference is the amount of memory that a program can actually use, where the 64-bit JVM allows for more than the 32-bit JVM.
As i remember there are some XUL library which depends of processor architecture.
So the way you need is emulate/virtualize eclipse environment x86 to run inside of x64 environment.
So the most expected exception should be XUL libraries error.
And one another life-hack could be switching to x64 libraries in x86 eclipse package, but its not guaranteed.
So, try to install x86 eclipse application to your environment and post here logs.
Regards
Eugene
Check answers for question Java programing for 64 bit JVM
It should not matter when you compile java code whether you compile for 32/64 bit.

java jre confusion

Could anyone please tell how jre directory help in the running java programs? I'm calling java interpretor by using java command, and that is in JDK directory, then how could jre directory help in running java programs and jdk for compiling?
When you install the JDK (development kit, compiler and so on), you get the JRE (runtime environment) as part of that (under my install, there's actually a jre subdirectory in the jdk folder) - this is because you will probably want to run code that you develop if only to test it a little bit before inflicting it on the rest of the planet :-).
But it's by no means necessary to install the JDK to run Java programs. All you need is the JRE and that is, by far, the normal situation for most people out there.
The JRE is just the interpreter (java.exe or whatever) - it's a smaller install that is typically used by people who just need to run Java applications and aren't Java developers. The JRE handles the conversion and execution of java bytecode for the target platform.
The JDK is meant for developers. Along with the runtime it provides the compiler and all the Java libraries that are used to build Java programs. The compiler is responsible for converting Java source code to bytecode.
So - when you are delivering your Java application to customers, all they need to install is the JRE.
The Java Runtime Environment (JRE) interprets byte code to platform specific machine code. JRE is minimal set of programmes which executes the java class files.
The JDK (Java Developmental Toolkit) comes along with java libraries and JRE embedded in it. Apart from these it comes along with the utility tools for byte code compilation "javac".

Categories

Resources