Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Questions about JAVA
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00300246
Message ID:
00300882
Views:
20
I passed this question to our Java coder and this is his response...

***
(1) Can JAVA code be compiled to a WIN EXE to create desktop applications?

Java can be compiled to a Windows EXE. Symantec’s Visual Cafe, IBM’s Visual Age, and others support this.
(2) Why is JAVA said to be slow?

For the most part Java’s slow performace is a thing of the past. Java’s performance is significantly better than it was a year or two ago. Some applications still seem a bit sluggish though. For the things I’ve written and one of our co-ops has written Java has performed well. It biggest advantage is protecting developers from system and application crashes that were possible in C/C++, and also taking over memory management instead of worrying about freeing dynamically allocated memory. A garbage collector does that job now. Structured exception handling (error handling) is a requirement and not an option as in C++. The benefits far outweigh any decrease in performance. It makes programmers far more productive and systems far more stable. It’s also a blast to program in.
I think Java is over 3 years old now and most people that develop with it still don’t understand it well enough to write efficient code. It’s syntax is similar to C/C++ but it’s workings are far different. I think that Java’s taking the slow performance blame due to people using their previous programming language techniques in Java. For instance, in Java all instances of objects are allocated on the heap. This allows the garbage collector to handle all “freeing” of objects when they are no longer referenced in the program. This takes the burden of managing memory deallocation and memory leak mistakes off of the programmer’s shoulders. In turn the programmer needs to know how to write code as to not overburden the garbage collector, slowing the system down while the collector runs in a background thread. I don’t think there are many people that understand how to program for the platform yet and blame their mistakes on it. This should change as people get more experience with it.
There are better alternatives to compiling Java to an EXE to gain performance. By using a Just-In-Time (JIT) complier the Java bytecode will be compiled into a native executable format like in an EXE. This is done just before program execution so it allows you to distribute binary portable Java bytecode but still run at native code speed. The next option is to use something like Sun’s HotSpot dynamic compiling technology. It runs the code in a profiler so at runtime it will decide if enough performance can be gained to make up the time to dynamically compile it to native code. The profiler will also learn code execution patterns to reoptimize and recompile the code while the it’s executing. This promises to outperform C/C++ for long term program exection since it can reoptimize itself if conditions in the execution of the code or code environment change. C/C++ is optimized at compile time and remains static at that point, so it’s can’t adjust to changing environmental conditions.
(3) Can you use ActiveX
controls in JAVA? ADO ?
Sun’s JDK comes with an ActiveX bridge to make use of ActiveX components from Java. Microsoft’s (J++) Virtual Machine allows JavaBeans to be accessed as COM components.
Microsoft also has JDirect which isn’t a standard Java technology and is not portable to any other platform. It allows Win32 calls to be called more directly in Java, but this isn’t the best way to do this as they would like you to believe. It just adds Win32 platform dependencies to the code. JDirect makes you handle all the Win32 API call C parameter setup and C error handling in Java where’s it’s not very natural to do. Win32 is a C language API and most Win32 functions take C structures with pointers as arguments. This has the potential to break Java security since Java doesn’t allow direct access to any pointers.
A far better and more portable solution is to use Sun’s Java Native Interface (JNI). JNI is part of the Java standard, but not supported by Microsoft forcing developers to use JDirect if they want to use the Microsoft Virtual Machine. It allows the developer to make a call to a C function and pass in Java arguments and throw Java exceptions on errors. This allows the Java developer to handle things in the Java fashion and makes the code readable and portable. Java handles translating the arguments from Java to C format then you handle all the Win32 API calls inside the C function where it’s a far easier thing to do, leaving the Win32 API programming to the C programmers where it belongs and not the Java programmers. You just have to recompile the C code on the destination plaform, but the Java piece will not have to be recompiled.
(4) Can a JAVA application call methods on a VFP COM server?

What does VFP stand for? Java can make COM calls using JNI and I also think the ActiveX bridge and JDirect will do that.
(5) Can you create COM objects with JAVA?

JavaBeans are Java classes that following the JavaBean convention. It’s just a class, method, and event naming convention. Microsoft’s Virtual Machine will expose JavaBeans as COM components.
Take a look at Enterprise JavaBeans (EJB). It’s a binary portable enterprise component architecture but you do have to write the components in Java, where CORBA and COM are language independent component architectures. This isn’t much of an issue since almost every Application Server will also expose the EJB’s as CORBA and COM components without the developer even having a concern about which will be used in the end. CORBA and COM components have to be bridged where EJB’s are easily exposed as other component model types. EJB also uses Internet InterOrb Protocol (IIOP) which is the standard object protocol on the wire for component communication. Both Java Remove Method Invocation (RMI), EJB, and CORBA are implemented with IIOP. DCOM is still based on RPC’s which are plain networkable function calls which are not tied to any instance of an object. Don’t be fooled by Microsoft’s new Simple Object Access Protocol (SOAP). It’s just RPC converted to XML and routed over the HTTP protocol. It’s still not object oriented. It’s only goal is to easily get through firewalls and there are security issues being raised about it.
(6) In a web browser, does JAVA and client side scripting do the same things (i.e, run code to respond to DHTML events)?

In general Java and client side scripting can do similar things but are very different. Java is a general programming language and can do more than a scripting language, but simple scripting languages may be sufficient for a lot of things. I don’t think Java has a direct link to DHTML events but is bridged with JavaScript. Usually the events are caught by JavaScript and just passed onto Java with a single line of scripting code.



**** Hope this helps
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform