Does Javac converts class into .h files

S

Sanny

What does Javac does to a Java Class? I heard it generates .h files

Does it convert Java Program into a C Program Any help will be
expected. I am considering converting a Java Program into C Program to
increase its efficiency.

Bye
Sanny
 
D

Daniel Dyer

What does Javac does to a Java Class? I heard it generates .h files

Javac is the standard Java compiler. It converts source files (.java)
into class files (.class). Are you confusing it with javah, which
generates C header files for classes with native methods?

Dan.
 
A

Andrew Thompson

Sanny said:
What does Javac does to a Java Class? I heard it generates .h files

You have now started three separate threads based
around converting your Java into ..an exe or C++
or whatever, based on the misunderstanding that it will
become faster.

Thus far, you have resisted my attempts to further
analyse your applet so I might make recommendations.

Basically - I am not convinced that
- writing this applet in any other language
will (necessarily) make it run faster.
- the applet code is as fast as it might be.

Perhaps you should be investigating why the code
is so 'slow', before rushing off to other langauges
or launch methods.

So I repeat - what is an URL for the applet?

Andrew T.
 
T

Thomas Fritsch

Sanny said:
What does Javac does to a Java Class? I heard it generates .h files

Does it convert Java Program into a C Program Any help will be
expected.
It seems you are intermixing several different things:
(1) The java-compiler javac (not javah) produces a Java class file (*.class)
from java source file (*.java)
(2) javah produces a C header file (*.h) from a from Java class file.
It does not generate any executable C code. It generates only C
declarations, which will be the interface between Java code (in *.class
file, generated by the javac compiler) and C code (in *.c files, to be
hand-written by you).
 
A

Andrew Thompson

Andrew said:
....
So I repeat - what is an URL for the applet?

E.G. is this the mess you are referring to?
<LOUD sounds warning>
http://www.getclub.com/Chess.html
</LOUD sounds warning>

That is one horrendously broken piece of (D)HTML.

The page seems to be doing continual (and very
irritating) fetches. The entire page needs to be
validated, and the scripts externalised and debugged.

The class file is not in a jar file (which compresses
it and speeds download time). The music (whatever
it is) should be included as a separate resource
(or even better still, not included at all) and played
only on request - who wants to listen to crappy,
(through most soundcards) music while playing
*chess* anyway?!

...Is that what that applet is for? I had refused the
'give a nickname' crap and ended at some default
screen, so it was impossible to go further.

I can tell you this though. If your HTML and JS
skills are indicative of your ability to write Java
and C/C++,
a) the applet is slow because of the code
b) writing it in another language will result in
another binary - that will also run slow.

Andrew T.
 
S

Sanny

(2) javah produces a C header file (*.h) from a from Java class file.
It does not generate any executable C code. It generates only C
declarations, which will be the interface between Java code (in *.class
file, generated by the javac compiler) and C code (in *.c files, to be
hand-written by you).

Ok javah creates .h file for the Applet. Then how can I use .C files So
that Applet Calls .c files to compute time intensive calculations.

Could it be done.

Say I have a Java class ABC.class with 3 functions

I create ABC.h file for that class.

Now I create ABC.c file which implements the three functions.

Now I want to utilize functions in ABC.c So how will I make a call to C
files created from the Java Applet ABC.class

Bye
Sanny
 
D

Daniel Dyer

Ok javah creates .h file for the Applet. Then how can I use .C files So
that Applet Calls .c files to compute time intensive calculations.

Could it be done.

Say I have a Java class ABC.class with 3 functions

I create ABC.h file for that class.

Now I create ABC.c file which implements the three functions.

Now I want to utilize functions in ABC.c So how will I make a call to C
files created from the Java Applet ABC.class

Bye
Sanny

This sounds like a bad idea. Firstly, applets aren't really intended to
have native methods. Although it can be achieved with a signed applet, it
isn't sensible because you have no idea what platform the user is going to
be using. If you build an applet that runs only on Windows, I can't use
it on my Mac or Linux machines. And even if I am using Windows, I'd have
to be stupid to grant you the necessary privileges to get the code to run.

Secondly, despite the myths, using JNI rarely improves performance
significantly (there are exceptions), it often makes it worse. There was
an article on java.net the other day about this
(http://weblogs.java.net/blog/mlam/archive/2006/12/beware_of_the_n.html).

You should address the issues that Andrew raised in his response before
going down this route.

Dan.
 
T

Thomas Fritsch

Sanny wrote:

[...]
I am considering converting a Java Program into C Program to
increase its efficiency.
Don't expect too much from this approach! Making a Java program more
efficient very rarely needs developing new C code (with javah & JNI).

(1) Usually the time-consumption of a Java program is concentrated around a
few hot-spots instead of being uniformly distributed. Be sure to spot these
performance bottle-necks by *testing* (with some kind of profiler tool)
instead of by *reasoning*. Guessing the bottle-necks only by intuition is
almost always (in my experience) wrong.
(2) Tuning the performance in most cases (in my experience) can be achieved
by optimizing the design of your Java code. There is rarely need for
replacing Java code by native C code.
(3) Be aware that there is already a huge amount of native C code (native
DLLs in Sun's JRE) working behind the scenes. For example for file I/O,
network I/O, uncompressing jar/zip/jpeg/gif files, painting on screen,
playing sound, ....
 
A

Andrew Thompson

Thomas Fritsch wrote:

....Be sure to spot these
performance bottle-necks by *testing* (with some kind of profiler tool)
instead of by *reasoning*. Guessing the bottle-necks only by intuition is
almost always (in my experience) wrong.

That is perhaps the best advice that has yet
come out of this thread(s).

Andrew T.
 
S

Sanny

(1) Usually the time-consumption of a Java program is concentrated around a
few hot-spots instead of being uniformly distributed. Be sure to spot these
performance bottle-necks by *testing* (with some kind of profiler tool)
instead of by *reasoning*. Guessing the bottle-necks only by intuition is

What are profiler tools How to get them and use.

Bye
Sanny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top