Java x86 compatible with Java ARM? - java

Can any given Java program written targeting an x86 platform also run on an ARM platform, or will there need to be OS-dependent code written to handle OS-specific functionality?

Yes. The Java runtime environment (JRE) includes a virtual machine which allows for true cross platform software. As long as you aren't using native libraries (or JNI), everything should be truly cross platform. Also, you need to check that the version level of the virtual machine is equivalent for some corner cases.

Related

Can I install java but not Java SE?

I've got a little question (just for a cultural purpose).
Would it be possible to download and install Java but not the standard edition ?
I know that Java SE contains basic and usefull functions / librairies (such as input /output).
Installing java without the "SE" is maybe useless and without any interest, but is it possible? if yes how ?
Many thanks,
Installing java without the "SE" is maybe useless and without any interest, but is it possible?
It is not possible. Oracle don't distribute a form of Java without libraries.
In fact, there is no such thing as Java without the libraries (SE or ME). The libraries are part of Java(tm) platform. If you managed to create something with the Java language and a JVM, but with partial, missing or incompatible libraries you couldn't call it Java1. Oracle owns the Java trademark, and they dictate the terms under which you are allowed to use it. If you used "Java" for a JVM / Library combination that doesn't pass the standard Java compatibility tests, you would likely get a "cease and desist" letter from Oracle's lawyers!
But more importantly, there is a significant subset of the Java SE runtime libraries that are essential for bootstrapping a JVM. If you were to build your own (ahem) Java build that left out critical classes, your JVM wouldn't work.
(And you cannot just simply2 write your own replacement for the Java SE library subset that the JVM depends on. There are many places where the C / C++ codebase for the OpenJDK JVM has intimate knowledge of the implementation details of the Java libraries. Figuring it all out ... from scratch ... would be challenging.)
Having said that, in Java 9 they introduced a tool called jlink which will produce a cut-down Java SE runtime for an application that only contains the libraries that are required by the application. Your can read about it here.
1 - For example, the Sun vs Microsoft lawsuit over Microsoft's attempt to "embrace and extend" Java 1.1. See What does Sun's lawsuit against Microsoft mean for Java developers?
2 - It's not impossible. Just a lot of really hard work.
The java command is traditionally from a SE installation. Typically in the JRE form, but occasionally I the JDK variation for advanced users. Others exist but are not for desktop usage.
So in that view you cannot install java without SE.
(note: Java EE is not a distribution as such but an API typically provides by big web servers)
Can I install Java but not Java SE?
Install? No. Not from any "official" distributions provided by Oracle, at least.
Why not?
Because Oracle doesn't package it that way. They offer 1) a Java SE development kit (JDK) which lets you create Java programs for yourself, or 2) a Java SE JRE which just lets you run Java programs that someone else created. There is no 3) Java without SE.
But couldn't they have given us option #3?
Could they have? Probably. Well, OK, maybe. Did they? No.
But theoretically it's possible, right?
Theoretically, I don't see why not. Theoretically, it ought to be possible to come up with a "Java" that's little more than a virtual machine and a compiler. Then, theoretically, using only this non-Java-SE Java language, you could either replicate the Java SE environment or develop an entirely new Java-based development platform.

Jvm comes with JDk or it default comes with os

I have a confusion of JVM. does it comes with os or JDK ,because I have read in many books ,it comes with JDK but JVM is not plat form independent it means that it comes with the os .Can any one clear my doubt?
Think of the JVM / JRE / JDK as a car:
The JVM (Java Virtual Machine) is the engine of the car. It's the essential part that makes the car run. Likewise with Java, the JVM is the engine that can run Java bytecode. It's the interface between Java bytecode and the operating system and hardware of the computer.
The JRE (Java Runtime Environment) is the rest of the car. To be able to drive a car, you need more than just the engine (the JVM). You need a chassis, wheels, a steering wheel, pedals, etc. The JRE provides everything around the JVM, such as libraries and tools needed to run Java programs.
The JDK (Java Development Kit) provides extra tools on top of the JRE that you need when you want to write your own Java programs. It contains the Java compiler and other tools that you need to create Java class files from source code.
On Oracle's website, you can download either the JRE or the JDK.
If you are an end user and you just need to run Java programs that other people have created for you, then the JRE is all you need. It's a complete car - it includes the JVM (the engine of the car).
If you are a programmer and you want to write your own Java programs, then you need the JDK. Oracle's JDK package includes the JVM and JRE, as well as the Java compiler and other development tools.
The JVM is provided by Oracle (or by another party, if you are using a different Java implementation than Oracle's). It is not normally included with the operating system.

Is the JVM a part of an OS or package?

I know Java Virtual Machine is used to run a java program independent of the OS.But can anyone tell me if JVM is the part of OS or a package.
Depends on your definition of OS, your definition of package and your actual OS.
Some OS vendors ship a JRE or JDK as part of their OS install in eigter core or extended sets. They all ship it as packages. This includes AIX, Solaris and some of the commercial Linux distributions.
However, without knowning your background it is safe to say it would be a stretch to consider Java to be a part of the OS itself. The one exception would be Android (however it is debatable if the Android VMs can safely be called Java :)
(Not talking about embedded and card os here).

Why java JDK gives option for all OS?

http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3-download-1501626.html
We know that java is a Platform Independent Language then why does this site provide JDKs for all OSes like Linux, Windows, Solaris?
Then why do we tell java is Platform Independent?
it is like this:
your application
---------------------
JAVA on OS1
---------------------
OS1
---------------------
hardware
---------------------
if you write your application on top of Java, then you can just move your java
application, as is, without changing it, or even compile it, to new OS, because
your program is written on one platform, which is Java, not the native OS.
So, you need to download specific Java for your OS. But from application point of view, it is the same API. Java makes your application platform independent since it hides the OS from your application. But Java itself, it has to be compiled and build for each specific OS. But the application do not care about that. The application sees the same API. That is the whole point.
Because there you download the Installer for the Java Virtual Machine. This is the environment where your Java Application is running in.
The reason why Java is OS independent, is because its running in this JVM.
The JVM's job is to hide the differences between platforms and to provide the same execution environment to application code regardless of platform.
The JVM is written in C++, and is compiled to a native binary, just like any other C++ application. (You wouldn't expect a .exe file to run on Linux, after all).
So the JVM is platform-specific, but the environment it provides is not.
To explain you in simple terms, you no need to compile your java source code when you move your code from one OS to another, but to run your compiled java code you need to have OS specific Java run time machine. Thats why you have different JDK for different OS.
To add to others answers, Java is qualified Platform independent because the code you write is supposed to works on every platform. That's not totally true in fact. The Java code is always compiled in bytecode in the same way, but the JVM interprets this common bytecode in different way in function of the OS, there is one JVM per OS. OS that don't have a JVM implementation to use bytecode can't support Java.

Tizen Mobile & IPad Linux - Does it allow GCC and Java?

https://www.tizen.org/ Tizen Mobile & IPad Linux very exciting.
Its allowing GCC. But does it run Dalvik JVM or OpenJDK?
Will then it will be compatible with 32-bit or 64-bit compilers?
Or we need to convert our source to be re-compiled using ARM compilers? of GCC?
Will it be easier to port C, Java code's now to Tizen? Where its complex and not natively available under Android phones/platforms?
As far as I know, it will be possible to package applications as DEB or RPM packages, you will be able to include an embedded VM (for example Avian VM) if you want, probably no JVM will be installed by default. JavaSE Embedded and OpenJDK should work (maybe with small modifications) under Tizen even though the documention only mentions C/C++ for native apps and HTML5/JavaScript for web apps. Moreover, there is no Java binding to its native APIs yet except those already available for Linux ARM and for APIs supported in any Linux distribution (for example JOGL 2.0). If you really need some help to use Java under Tizen, please contact the JogAmp Foundation here. Xerxes already succeeded in running JOGL 2.0 under Meego as you can see here, why not doing the same thing under Tizen?
N.B: Don't expect official Java support under Tizen.
If you check this two presentation from May:
Tips and Tricks: Designing Low-Power Native and Web Apps on page 3.
and this
Implementation of Standard Accessibility APIs for Tizen on page 9.
You see that basically Tizen will have two APIs and hence two types of applications:
Native;
Web(HTML5) pretty well documented already.
So no JVM or OpenJDK, don't know the Native API apps binaries will be compiled to but probably will know soon.
Since Tizen is pretty much in development you can check from time to time the official site.

Categories