On which API the JVM is based
Well I am new to Java, but I am a .NET developer. I am sure that .NET is a wrapper for the WinAPI32 on Windows, but what about Java? Is the Java VM also a wrapper for the WinAPI running on Windows or is it built up by different technolgies. If it is not a wrapper, can you tell how lots of Java Apps look like native XP apps ( I speak about the e.g. Control Center for Java).
What about the difference between Swing and SWT?
I am looking forward to hearing from you?
[485 byte] By [
hey_iana] at [2007-10-3 3:54:36]

The best answer I can give you is it depends.
First of all for VM's not on Windows it obviously isnt using the WinAPI. Further the original windowing tooklit in Java did use the native api on the system but Swing emulates (aka does not do this).
Obviously though the VM does interact with the OS extensively in other ways.
You don't see any of this though (most always). The VM is written in C++ if that is what your question is.
SWT is alternative windowing system for Java but not part of the standard runtime. Here's an article (SWT biased because it is on a SWT site) that explains it a bit http://www.eclipse.org/articles/Article-SWT-Design-1/SWT-Design-1.html
> First of all for VM's not on Windows it obviously
> isnt using the WinAPI. Further the original windowing
> tooklit in Java did use the native api on the system
> but Swing emulates (aka does not do this).
>
I am rather certain that it is in fact using the WinAPI. It might not be using all of it, but it is certainly using some of it even for the GUI.
Wow! Big respect to Sun Microsystems for the fast answers! It is great!
> The best answer I can give you is it depends.
>
> First of all for VM's not on Windows it obviously
> isnt using the WinAPI. Further the original windowing
> tooklit in Java did use the native api on the system
> but Swing emulates (aka does not do this).
>
OK so I understand Swing does not use WinAPI, but the original toolkit, on which Swing is based on uses it. It should be specific on each system (e.g. WinAPI on windows, X11 on GNU/Linux, etc.).
>
> You don't see any of this though (most always). The
> VM is written in C++ if that is what your question
> is.
Really? The VM is written in C++! This would be maybe a quite silly question but: Most C++ compilers are written in C++, why not to write the Java interpreter or JVM in Java? Why did you use C++ instead of the assembler or better machine code?
Here another question: Is there a RAD IDE for Java like Visual Studio, where I can find a designer like in C# to drag-n-drop all controls on a form and the add code by double-clicking? I am interesed in such an IDE because if there is one I would like to port my apps for Windows using Java to Linux and other UNIXes.
Thanks for the answers and I am looking forward to read more answers of you! ;-)
> Wow! Big respect to Sun Microsystems for the fast
> answers! It is great!
Sun Microsytems had nothing to do with the content of the replies. I don't work for Sun. Jschell doesn't work for Sun (at least I don't think he does).
We are Java developers who volunteer our time to answer questions here. You will rarely if ever run into Sun employees in these forums.
> The
> > VM is written in C++ if that is what your question
> > is.
>
> Really? The VM is written in C++! This would be maybe
> a quite silly question but: Most C++ compilers are
> written in C++, why not to write the Java interpreter
> or JVM in Java? Why did you use C++ instead of the
> assembler or better machine code?
As indicated above "i" didn't do this. I suspect jschell can give you a clearer reason for this decision so I will just leave it there.
>
>
> Here another question: Is there a RAD IDE for Java
> like Visual Studio, where I can find a designer like
There are a large number of Java IDE's with a variety of features. Many are free (open source etc) and some you pay for (but often get free trials).
If you search this forum you will find this topic is discussed ad nauseaum. I would suggest looking at a couple and seeing if the feature set and interfaces are what you are looking for.
As a start (just suggestions)look at Eclipse and Netbeans.
OK sorry I thought you are one of the developers from SUN.Well about the IDEs are tried Eclipse but it seems there is not designer in it, I am not sure what about NetBeans
> Well about the IDEs are tried Eclipse but it seems
> there is not designer in it
This is only sort of true.
Eclipse is just a base IDE. There are numerours plugins for extending functionality, including the kind of thing you are looking for.
For example http://www.windowbuilderpro.com/
> Eclipse is just a base IDE. There are numerours
> plugins for extending functionality, including the
> kind of thing you are looking for.
>
> For example http://www.windowbuilderpro.com/
OK you are right, but I do not want to pay money for such commercial IDEs. I am a freeware developer and do not make any money. Do you know something about the Java Developer Studio Enterprise. I was told there is a Visual Studio like designer. Is it true?
> > Wow! Big respect to Sun Microsystems for the fast
> > answers! It is great!
>
> Sun Microsytems had nothing to do with the content of
> the replies. I don't work for Sun. Jschell doesn't
> work for Sun (at least I don't think he does).
Last time I saw a post from anyone that claimed association with Sun was two years ago (or at least useful - not forum maintenance, etc)
> Really? The VM is written in C++! This would be maybe
> a quite silly question but: Most C++ compilers are
> written in C++, why not to write the Java interpreter
> or JVM in Java? Why did you use C++ instead of the
> assembler or better machine code?
>
Even assemblers these days are often originally written in C or C++.
Much of the VM is written in java. Even nothing else consider that without the Java API java is useless and the vast majority of that is java. But there are internals in java as well.
Actually quite a bit of code is generated as well. Although I believe the output of that is C++. But that means the source is a pseudo language.
Once you get rid of that then there is C++ code and (perhaps) some C code as while. That is necessary to get to the OS internals which java as a language does not provide.
> > > Wow! Big respect to Sun Microsystems for the
> fast
> > > answers! It is great!
> >
> > Sun Microsytems had nothing to do with the content
> of
> > the replies. I don't work for Sun. Jschell doesn't
> > work for Sun (at least I don't think he does).
>
> Last time I saw a post from anyone that claimed
> association with Sun was two years ago (or at least
> useful - not forum maintenance, etc)
That guy in the JDBC forum (Lance?) who posted this spring works for Sun. Although the usefulness of his posts was questionable IMO.
> > That guy in the JDBC forum (Lance?) who posted this> spring works for Sun. Although the usefulness of his> posts was questionable IMO.I must have missed that.
> >
> > That guy in the JDBC forum (Lance?) who posted
> this
> > spring works for Sun. Although the usefulness of
> his
> > posts was questionable IMO.
>
> I must have missed that.
No you participated in the discussion.
http://forum.java.sun.com/thread.jspa?threadID=667955
Your reply 40 I thought was an excellent summary.
> > >
> > > That guy in the JDBC forum (Lance?) who posted this
> > > spring works for Sun. Although the usefulness of his
> > > posts was questionable IMO.
> >
> > I must have missed that.
>
> No you participated in the discussion.
>
How did you decide that that person was from Sun (rather than perhaps just a JSP participant)?
I am interesed in such
> an IDE because if there is one I would like to port
> my apps for Windows using Java to Linux and other
> UNIXes.
>
If these apps were written in java, then for porting them to Unix or Linux you dont need to do snything since java is platform independatn. (Atleaat if the apps are written correctly)
> I am interesed in such
> > an IDE because if there is one I would like to
> port
> > my apps for Windows using Java to Linux and other
> > UNIXes.
> >
>
> If these apps were written in java, then for porting
> them to Unix or Linux you dont need to do snything
> since java is platform independatn. (Atleaat if the
> apps are written correctly)
You need to test them on each targeted OS.
> Really? The VM is written in C++! This would be maybe
> a quite silly question but: Most C++ compilers are
> written in C++, why not to write the Java interpreter
> or JVM in Java? Why did you use C++ instead of the
> assembler or better machine code?
The Java compiler is indeed written in Java. You don't write virtual machines (interpreters) in the language they interpret, if only for performance reasons. There are exceptions like Lisp which prove the rule ...
ejpa at 2007-7-21 10:19:45 >

Is Swing alos based on the WinAPI although this is not a wrapper? If not, from which shared libs the Swing draws the widgets if not using WinAPI?
OK so JVM (the Java Interpreter) and JRE are written in C++.
The compiler is written in Java iself, isn`t it? OK, but I did not hear about any Java compiler! I thought Java is an interpreted language, all I know is that there is a GCC port of Java, called GJC or so, which comiles Java .class files to native code. But this comiler seems to be written in C++ like mostly all tools form the GNU Compiler Collection.
Is it realy a better way to compile Java code to native code or is it better to let the JVM interpet the ByteCode?
> Is Swing alos based on the WinAPI although this is
> not a wrapper? If not, from which shared libs the
> Swing draws the widgets if not using WinAPI?
At some level swing uses some part of the Win API.
>
> OK so JVM (the Java Interpreter) and JRE are written
> in C++.
Only some parts
> The compiler is written in Java iself, isn`t it? OK,
> but I did not hear about any Java compiler! I thought
> Java is an interpreted language, all I know is that
> there is a GCC port of Java, called GJC or so, which
> comiles Java .class files to native code. But this
> comiler seems to be written in C++ like mostly all
> tools form the GNU Compiler Collection.
>
When you start with a 'java' file the compiler creates a 'class' file.
> Is it realy a better way to compile Java code to
> native code or is it better to let the JVM interpet
> the ByteCode?
There are native compilers.
The advantage of the byte codes is that the compiled version will run on different OSes.