Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Need to recompile a Java Applet as an Executable

Reply
Thread Tools

Need to recompile a Java Applet as an Executable

 
 
Sanny
Guest
Posts: n/a
 
      01-29-2010
I have a Java Applet which is quite slow.

There are a few functions that are called by the Java Applet. I want
those functions to be run as fast as possible.

One Option is to use Native Support.

Does an Applet support native language?

Can I create a C++ / C function and ask the applet to call that C
function that is run on Users Computer? And get back the output and
display on the Applet?

I just want a few functions to use fast C/ C++ access?

How to distribute my applet with C/ C++ dll/ That Applet accesses?

I will have 2 versions of Applet. One the slow version the other the
fast version.

I want that users who are not satisfied with the slow version. They
will need to use the Signed Applet. Once they allow the Signed applet
to access the Computer. The applet will load the C/ C++ dll / ActiveX
on the Computer / Webpage.

I want communication between Activex and the Applet for quick
computation.

Will the Activex/ DLL be 10-20 times faster than an Applet?

So for power users who are looking for better performance I allow them
to use the C/ C++ version.

Will this model work?

Will I have to create different ddl/ ActiveX for different platforms?

Say for Mac os/ Linux/ Windows etc? Do I need to create a different
ActiveX?

I just have a few functions in C/ C++ and the Applets sends the
parameters and returns the output.

Which C/C++ free package should I use to create this function. I just
want a few functions to be executed quickly by native language and
return the output to the applet. So I want a free editor where I can
compile the C/ C++ functions.

Second Question Will an Activex/ DLL on a webpage be as fast as any
executable? I am looking for the fastest options.

Please suggest me a good example or diagram of how to proceed. Will I
need Corba/ XML feature for Applet & Activex communication? Will this
setup work on all web browsers?

Does flash works faster than Java? Can I use those functions in Flash.
Wil a function run on Flash as fast as a Native Language?

Bye
Sanny

Good opportunities for Java/ C/ C++ Experts:

http://www.getclub.com/Experts.php

Tell your Expertise and projects.
 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      01-29-2010
On 29 Jan, 07:53, Sanny <(E-Mail Removed)> wrote:

> I have a Java Applet which is quite slow.
>
> There are a few functions that are called by the Java Applet. I want
> those functions to be run as fast as possible.
>
> One Option is to use Native Support.
>
> Does an Applet support native language?
>
> Can I create a C++ / C function and ask the applet to call that C
> function that is run on Users Computer? And get back the output and
> display on the Applet?


this isn't on topic on comp.lang.c how C or C++ "links" with java is
outside the scope of the C or C++ language.

<snip>
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      01-29-2010
Sanny wrote:

<snip>

> Say for Mac os/ Linux/ Windows etc? Do I need to create a different
> ActiveX?


This is about the nearest thing to a C question, and even this is not a
C question...

Of course any compiled C code would have to be compiled for the specific
target it is running on...

<snip>

> Does flash works faster than Java? Can I use those functions in Flash.
> Wil a function run on Flash as fast as a Native Language?


You probably need to ask in a web authoring group/forum, since your
problems are all heavily to do with a web site. However, I would
recommend from my experience that you would be better off looking at a
higher level, ensuring that only what is needed is being downloaded etc.
I've seen sites where as much as 90% of what was downloaded was not
actually needed by the client! How to do this is all about web
authoring, and not Java (which is NOT Javascript) or C.
--
Flash Gordon
 
Reply With Quote
 
Sanny
Guest
Posts: n/a
 
      01-29-2010
> Sanny wrote:
> > I have a Java Applet which is quite slow.

>
> > There are a few functions that are called by the Java Applet. I want
> > those functions to be run as fast as possible.

>
> You should probably fix your Java code then. *It's rare for Java
> performance to be so critical that you need to go outside of Java. *And
> you almost certainly won't get the 10x or 20x speedup you seem to be
> hoping for.


There is nothing wrong with the java code. I know some expressions in
C are working 10-20 times faster. Secondly "C" allows the use of
pointers and Assembly language programming.

Also I can configure Compilation in "C" such that it do not do error
checking at runtime speeding it up further.

My program does a lot of array sorting and array search and
comparisions. That is quite faster in C. Also lot of String Operation
is done.

In Java String Operations are 100 times slower than in "C". As copying
a string takes lots of time in Java.

> > One Option is to use Native Support.

>
> You can easily make things slower, if you do that wrong. *And it won't
> necessarily be faster in any case. *IMHO JNI is more appropriate for
> when you need some specific functionality that's simply not available in
> Java, or you need to reuse some code that would be impractical to port
> to Java.
>
> No doubt there are some specific, very specialized applications in which
> writing some custom native code and calling it via JNI is helpful. *But
> statistically speaking, it's not likely your program is in that category.



One more reasion to use "C" is to have my code encrypted. Java Code is
available to all so others can easily hack the java code. While
cracking an Activex is I suppose impossible.

> > Does an Applet support native language?

>
> > Can I create a C++ / C function and ask the applet to call that C
> > function that is run on Users Computer? And get back the output and
> > display on the Applet?

>
> Unfortunately, I don't know much about applets. *But due to security
> concerns, I would expect applets to have much more restricted access to
> JNI than regular Java applications.


I have full understanding of these. Only problem is how Browser
accepts the Activex and Applet.

Will a firefox browser run an ActiveX on Non Windows OS?


> But, I suspect you don't really need to use JNI.
>
> > [...]
> > Will I have to create different ddl/ ActiveX for different platforms?

>
> > Say for Mac os/ Linux/ Windows etc? Do I need to create a different
> > ActiveX?

>
> ActiveX is Windows-only. *Each platform has its own library format and
> supported CPUs. *If you want a platform-specific solution, just write
> the whole thing as native code.


OK, I can ask the users to purchase Windows operating System if they
want faster version. Thats not a big problem. I suppose 80-90% will
already have a windows version.


> If you want cross-platform support, write the whole thing in Java,
> figure out why your program is so slow, and fix it using only Java.


Its not Slow exactly. But I want it to be more fast. As C/ C++
routines are much faster as I can use Assembly language programming.

Bye
Sanny

Good opportunities for Java/ C/ C++ Experts:

http://www.getclub.com/Experts.php

Tell your Expertise and projects.
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-29-2010
Sanny wrote:
> Will a firefox [sic] browser run an ActiveX on Non Windows OS?


ActiveX is inherently Windows-only.

--
Lew
 
Reply With Quote
 
Nigel Wade
Guest
Posts: n/a
 
      01-29-2010
On Fri, 29 Jan 2010 08:49:26 -0500, Lew wrote:

> Sanny wrote:
>> Will a firefox [sic] browser run an ActiveX on Non Windows OS?

>
> ActiveX is inherently Windows-only.


It's inherently Internet Explorer on Windows.

It is not supported in Firefox on any platform.
http://support.mozilla.com/en-US/kb/ActiveX

--
Nigel Wade
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      01-29-2010
On 01/29/2010 06:33 AM, Sanny wrote:
> There is nothing wrong with the java code. I know some expressions in
> C are working 10-20 times faster. Secondly "C" allows the use of
> pointers and Assembly language programming.


That's not always a good thing. <Segmentation Fault>

> One more reasion to use "C" is to have my code encrypted. Java Code is
> available to all so others can easily hack the java code. While
> cracking an Activex is I suppose impossible.


*Laughs heartily*
Two words: IDA Pro.
Native code is not immune to being cracked. Indeed, with modern tools
(both Java obfuscators and native disassemblers), it is generally as
easy as Java to crack in many cases. C has the unfortunate problem of
being a wonderful language to target for decompilers.

> I have full understanding of these. Only problem is how Browser
> accepts the Activex and Applet.
>
> Will a firefox browser run an ActiveX on Non Windows OS?


No. Firefox doesn't support ActiveX period. Well, at one time there was
a framework to embed Gecko in ActiveX, but that stopped working several
years ago IIRC.

Even IE is shying away from ActiveX IIRC.

> Its not Slow exactly. But I want it to be more fast. As C/ C++
> routines are much faster as I can use Assembly language programming.


It sounds like you're not even trying to optimize in Java, just claiming
that it will be faster since you can use assembly, that unmaintainable
little bugger.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      01-29-2010
On 29 Jan 2010 at 8:01, Nick Keighley wrote:
> this isn't on topic on comp.lang.c how C or C++ "links" with java is
> outside the scope of the C or C++ language.


Utter nonsense.

 
Reply With Quote
 
BGB / cr88192
Guest
Posts: n/a
 
      01-29-2010

"Antoninus Twink" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 29 Jan 2010 at 8:01, Nick Keighley wrote:
>> this isn't on topic on comp.lang.c how C or C++ "links" with java is
>> outside the scope of the C or C++ language.

>
> Utter nonsense.
>


usual answer by the regulars would be something like "the C standard makes
no mention of JNI or JVMTI, or JNA, ..., and hence these features are
outside the scope of C" (much like is the position WRT: threads, POSIX,
OpenGL, ...).

granted, to accomplish much of anything useful in C, one generally has to go
outside the narrow bounds that are "the standard".


granted, this is not exactly the issue as with the original post.
anyways, assuming that the browser is not using a poor JVM implementation (a
plain interpreter or similar), Java vs C performance is not likely to be
significant enough to bother worrying about in this case, and one is instead
better off concerning themselves with writing efficient code (any language
will be slow if the programmer doesn't know what they are doing, and usually
the language/compiler is the first thing to be blamed for the poor
performance of badly written SW).

actually, it is worse with non-prgrammers, who are more naturally inclined
to either blame the computer or imagine that the task itself is just too
complicated, rather than consider that it may be instead that the app is
just poorly written...


as far as Java vs Flash:
actually, Flash is likely to be much slower than Java (or at least, for any
tasks where non-trivial code is needed, Flash may be a better choice when
much of the basic functionality is already built into the Flash backend,
such as for 2D/3D animations or video players...).

or such...



 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      01-29-2010
On 29 Jan 2010 at 21:42, BGB / cr88192 wrote:
> anyways, assuming that the browser is not using a poor JVM
> implementation (a plain interpreter or similar), Java vs C performance
> is not likely to be significant enough to bother worrying about in
> this case, and one is instead better off concerning themselves with
> writing efficient code (any language will be slow if the programmer
> doesn't know what they are doing, and usually the language/compiler is
> the first thing to be blamed for the poor performance of badly written
> SW).


To be honest, whatever stories people come up with about how good their
JIT compiler is at optimizing on the fly and such like, the truth is
that for many applications, rewriting the bottleneck in C will gain you
an order of magnitude.

I believe the principal two reasons for this are:

1) No overhead in basic data types. AIUI, Java will take many bytes to
store a simple int, just because of all the OO book-keeping that needs
to accompany every single object. Therefore, smaller slices of every
array can fit in cache ---> performance death.

2) Java hides what's going on under the hood from the programmer. This
abstraction is great for reducing coding time, but it means people
unwittingly do things that cause lots of temporary variables to be
created (which might themselves depend on constructing half a dozen base
classes), or they keep generating lots of junk on the heap instead of
making one allocation and recycling it themselves, so that GC becomes a
killer.

In Java (and C++ for that matter), the possible expansion factor of a
single source line into assembly instructions is essentially unlimited,
whereas with C you generally see what you're getting.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to recompile a Java Applet as an Executable Sanny C Programming 34 02-03-2010 09:12 AM
Re: Need to recompile a Java Applet as an Executable Paul Cager Java 0 01-29-2010 12:25 PM
Do we need to recompile all libraries after we modify the class? Vols C++ 2 07-11-2006 01:53 PM
Recompile jsp with java classes? JGH Java 6 02-23-2005 03:46 PM
Do I need to recompile if I make a small change Simon Harvey ASP .Net 1 02-13-2004 09:17 AM



Advertisments