Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Does Javac converts class into .h files

Thread view: 
Sanny - 11 Dec 2006 10:45 GMT
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
Daniel Dyer - 11 Dec 2006 10:56 GMT
> 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.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Andrew Thompson - 11 Dec 2006 11:20 GMT
> 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.
Andrew Thompson - 11 Dec 2006 11:38 GMT
> > What does ...
...
> 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.
Thomas Fritsch - 11 Dec 2006 11:21 GMT
> 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).

> I am considering converting a Java Program into C Program to
> increase its efficiency.
>
> Bye
> Sanny

Signature

Thomas

Sanny - 11 Dec 2006 12:05 GMT
> (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
Daniel Dyer - 11 Dec 2006 12:31 GMT
>> (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
[quoted text clipped - 18 lines]
> 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.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Sanny - 11 Dec 2006 12:48 GMT
> Secondly, despite the myths, using JNI rarely improves performance
> significantly (there are exceptions), it often makes it worse.  There was
[quoted text clipped - 3 lines]
> You should address the issues that Andrew raised in his response before
> going down this route.

Thanks for your sincere help.

Bye
Sanny
Thomas Fritsch - 11 Dec 2006 15:22 GMT
[...]
> 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, ....

Signature

Thomas

Andrew Thompson - 11 Dec 2006 15:39 GMT
<snip>
All good explanations, but just wanted to requote this part..

> ....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.
Sanny - 12 Dec 2006 05:48 GMT
> (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
Thomas Fritsch - 12 Dec 2006 12:26 GMT
>> (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.

See for example <http://mindprod.com/jgloss/profiler.html>

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.