Is it possible to make non-virtual calls in Java?

Hi all,
I'd like to hear some expert's opinion about this: if I mark a class as final, its method call will not be virtual? that is, there won't be "late binding" in the Virtual Machine? or still the JVM binds its calls at runtime ??
I'm asking this because I had a long discussion with a guy programming in C++ that claims that ALL java calls are virtual, while on the other hand in C++ ONLY those declared as "virtual" are in fact virtual call.
So he says that this is the reason why Java will be always slower then C++.
I'd like to hear your opinion/feedback
Regards
Francesco

About this being "the reason" why C++ will
always be faster than Java: it's not. The main reason
C++ is faster than Java is that Java needs to run its
code through the virtual machine...No, that's not a reason for Java to be slower. In practice, Java code is compiled to native code on the fly, so it does not "run its code through the virtual machine."
One main reason why Java is slower than C++ is that it keeps all objects on the heap instead of on the stack. Take a look at this article on optimizing code: http://www.pgh.net/~newcomer/optimization.htm Less than halfway through the article, the author describes a performance bottleneck in a memory allocation routine. By changing the memory to be allocated on the stack instead of on the heap, the program ran about twice as fast.
Allocating memory on the heap is one of the slowest operations in Java. Programs that allocate lots of objects are going to be slow.

Similar Messages

  • How do i make UNIX system calls in Java app?

    Is it possible to make UNIX system calls in a java app? I.E. perform a file copy/move to another machine within a program.
    Thanks,
    Erik

    If there is a command line tool then you use Runtime.exec() otherwise you have to use JNI.
    If you want to access shared libraries you might want to look at www.swig.org

  • Is it possible to make a phone call (not FaceTime) from my iPad if I'm using 3G and not Wi-Fi?

    I was tyring to send a text message or make a phone call from my iPad when I was on hotspot with my iPhone but it didnt work...
    I use this feature when I'm at home on Wi-Fi. I would like to know whether this is possible or not...
    Thanks in advance

    No, the feature works at home by going through your iPhone to make the call.
    There are Apps for the iPad which allow this: Skype, etc.

  • Is possible to make webservice that call another webservice??

    i already make 1 webservices(a) project and also make a class file that invoke another webservice(b)... when i test with SOAPUI to invoke my webservice(a), it failed. but when i make a main class and run as an application (standalone), everything is going good.
    is possible to make a webservices n invoke another webservices??????? if yes, can u give me an example..???

    yes its possible. I have written a web service that is part of our system that calls a third party system and passing credentials across to amalgamate data from 2 distinctly separate systems. A call is made to my webservice and in the code for that service I invoke a method on a set of stubs built against a third party wsdl.
    Similarly for smart card authentication users first call my webservice, but as I am not responsible for the smartcard validation itself I call another departments webservice, this time its a message based service and not RPC but either way I still build a SOAP message and then send it to a service which then does the smartcard validation for me.
    They are both working examples of a web service calling another web service.

  • Is it possible to make a phone call from contact in Cambodia with Miss Siri ?

    I've got a Iphone 4S which's shiped from Singapore , love it so much . But one thing , i couldn't understand , many thing i can ask Miss siri to do for me exclude make a phone call for contact or any number . I tried to use 10 digits number of my contact , she responsed " Sorry [Myname] , i can't call [contact name]" , and then i tried with 11 digits , she still responsed as previous question .... I'm so doubt that , last time , i tried with my country code : +855 or 855. and then i restarted my iPhone 4S . She still made me angry .......... ....... Anyone please tell me how to use Miss Siri to make a phone call ? ( Note : Location : Cambodia , Phnom Penh City )

    No, the feature works at home by going through your iPhone to make the call.
    There are Apps for the iPad which allow this: Skype, etc.

  • Is it possible to make a facetime call from an iPod Touch to a computer?

    My iPod Touch 4G is now capable of video chat. My computer (and my long-distance girlfriend's computer) are capable of video chat. As far as I can tell, those devices are unable to communicate with each other. I use Skype to video chat computer to computer, and I thought my new iPod Touch 4G would be able to call her computer on the go (so long as I'm in a decent wifi network.) Skype doesn't seem to be able to access that camera, though, and does voice only when I call. Facetime can access that camera, but as far as I can tell is incapable of calling anyone using a device other than another iPod Touch or iPhone.
    Is there any way for Facetime (or any other app I can download to my iPod Touch) to video chat with a regular computer? I don't understand why Apple would overlook this, if it's the case (and not just my inability to figure it out.) It seems basic that if I can video chat with another iPhone or iPod, I should be able to do the same with a properly equipped computer.

    northernlights78 wrote:
    Yes, get the "Yahoo! Messenger" app from appstore, my ipodtouch 4g works fine both in desktop and on laptops, your ipodtouch should work fine too... and if you have the yahoo messenger apps already in your ipodtouch make sure u have the latest update/version.
    cheers!
    The subject of this topic is make a "facetime" call to a computer.
    YM is not FaceTime and cannot connect to FaceTime. I am happy YM works for you, but it does not respond to OP swagmonkey's request.
    *Readers looking for a way to FaceTime on a computer must use FaceTime for Mac* (beta.)
    • FaceTime for Mac (beta): http://www.apple.com/mac/facetime/
    • Alternate: http://download.cnet.com/Apple-FaceTime/3000-2349_4-75322304.html
    Mac Pro Quad Core (Early 2009) 2.93Ghz Mac OS X (10.6.4); MacBook Pro (13 inch, Mid 2009) 2.26GHz (10.6.4)
    LED Cinema Display; G4 PowerBook 1.67GHz (10.4.11); iBookSE 366MHz (10.3.9); External iSight; iPod touch 4.1

  • Is it possible to make a code editor in Java?

    I'm new to java and so i'd like to know if it would be possible to make a simple code editor for Mobile Phones with Java.
    The code editor will be for GML.
    I'd like to make it so that the code can be easily edited on a wide range Mobile phones (not necissarily smart phones).
    If this is possible, I would greatly appreaciate any help or advice. Thanks.
    skinnyeddy

    TuringPest wrote:
    Hippolyte wrote:
    skinnyeddy wrote:
    "first list the areas in which you are proficient" - I'm not. I thought it would be easy to make a simple text/code editor in java without any experience. That was a bit of a mistake. Looks like I'll have to learn the hard way :SIMHO, one should woodshed it, work on programming basics and object-oriented programming fundamentals, in Java for at least one year before attempting to write any GUI code. Even day in this forum we see what code looks like when this advice is not followed.my first java code 5 years ago was an applet with a changing 2d function being animated.
    it worked after 2 grueling days and i was so happy because visual feedback was my only motivation.
    so its hard to say. granted, my code was awful for a long time.I'm thinking of the guy last week who had Swing+JDBC code and kept pestering for help on an obvious syntax error (he was invoking a method with no arguments when it was defined to take a String array) and for the life of him, he couldn't see the error or understand the error message. Posters kept telling him to learn the fundamentals first, but he was stubborn and kept demanding someone fix his syntax error...

  • Possible to make non-HD channel switch to HD channel? (like 7 to 507)

    Hey, just got Fios installed this week and am liking it so far.
    Quick question... I had Cablevision before this, and they had it set up so that if you put on an non-HD channel using an HD set top box, it automatically switched to the HD version of that channel.
    Is there any way to make this happen with Fios? So like... if I put on 7, it would automtically change to 507.
    Thanks in advance for any help.
    Solved!
    Go to Solution.

    Welcome to FiOS, and welcome to the forums!
    Unfortunately no. But if you will take the time to set up a Favorites list, if you haven't already done so, then you can at least somewhat minimize accidentally surfing to the SD channel by mistake. If you are interested in setting up a Favorites list, here is a link to a thread which should help you get started:
    http://forums.verizon.com/t5/FiOS-TV-Technical-Assistance/Exploiting-FiOS-TV-Favorites/td-p/9935
    With my Favorites list I have all of the HD channels I care about included, and only those SD channels I am interested in that are not duplicated by HD channels. And I must admit, it is pretty rare that I ever watch any SD channel any more.....
    Justin
    Verizon FiOS TV, Internet, and phone
    QIP6416-P1, IMG 1.7.1, Build 09.97
    Keller, TX 76248

  • Is it possible to make an Autostart application in Java?

    Hi,
    I have some stuff that I would like to burn on a CD and I thought that it would be very nice if I could put an autostart application on the same CD which would start as soon as I put this CD in CD-drive. I dont know whether this can be done in Java. I am using Excelsior Jet so I would make this as an usual autostart.exe application.
    Thanx

    The only thing you have to do, is to put the JRE on the CD as well. Say in sub-directory jre (you can copy the jre folder from your JDK installation)
    I'm not sure how the autostart stuff works, but as far as I can remember it's just the name of an exe. So you could put someting like
    jre\javaw.exe -jar MyApplication.jar
    into the autostart definition

  • Make Cell Phone call ?

    Hello,
    It's simple question:
    How could I make cell phone call from Java class ?
    Is there any required hardware or Java library ?
    Thank you very much

    Tiny_Oracle wrote:
    How could I make cell phone call from Java class ?
    Is there any required hardware or Java library ?Well, required hardware would be a cellphone or a similar hardware system that can actually perform the required sending.
    I can imagine a native library would be needed, unless the JTAPI has really improved since I last looked at it.
    Usually people attempt to send an SMS via Java, what were you planning to do with actual cell phone calls?
    Also I'd recommend serious googling.

  • BAPI function call in Java

    Hi,
    I am trying to make BAPI function call in JAVA. I am using the following libraries for IBM AIX version and the sapjco.jar
    1) librfccm.o
    2) libsapjcorfc.so
    The above 2 libraries are in my java lib path.
    But I get a exception and it is referring to sapjcorfc.dll (which is a windows version) instead of referring to libsapjcorfc.so
    What should I do so that it refers to libsapjcorfc.so and not sapjcorfc.dll
    Error Details:   java.lang.ExceptionInInitializerError: JCO.classInitialize():
    Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
    JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc
    [sapjcorfc (A file or directory in the path name does not exist.)]. java.library.path
    [/usr/java14_64/jre/bin:/usr/java14_64/jre/bin:/usr/java14_64/jre/bin/classic:/usr/java14_64/jre/bin:
    /usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:
    /tmp/sapinst_exe.1081378.1199455057:/usr/sap/DP0/SYS/exe/run:/home/db2inst1/sqllib/lib64:
    /usr/sap/DP0/DVEBMGS42/exe::/usr/lib:/usr/sap/DP0/DVEBMGS42/j2ee/os_libs:/usr/sap/DP0/DVEBMGS42/exe:
    /usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:/usr/lib:/lib:/usr/sap/DP0/SYS/exe/run:
    /home/db2inst1/sqllib/lib64]

    Hi Jawed,
    when  I try it as a stand alone java code on IBM AIX version BAPI connection works and it fetches the roles listed for an user from the ACTIVITYGROUP table.
    The same piece of code bundled in an ear and when deployed in SAP netweaver portal gives different errors. My sapjco.jar is in application lib folder and it is referred in classpath
    first time when i access the application url it gives me
    Error Details: java.lang.ExceptionInInitializerError: JCO.classInitialize():
    Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
    JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc
    http://sapjcorfc (A file or directory in the path name does not exist.). java.library.path
    [/usr/java14_64/jre/bin:/usr/java14_64/jre/bin:/usr/java14_64/jre/bin/classic:/usr/java14_64/jre/bin:
    /usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:
    /tmp/sapinst_exe.1081378.1199455057:/usr/sap/DP0/SYS/exe/run:/home/db2inst1/sqllib/lib64:
    /usr/sap/DP0/DVEBMGS42/exe::/usr/lib:/usr/sap/DP0/DVEBMGS42/j2ee/os_libs:/usr/sap/DP0/DVEBMGS42/exe:
    /usr/sap/DP0/DVEBMGS42/exe:/usr/sap/DP0/DVEBMGS42/exe:/usr/lib:/lib:/usr/sap/DP0/SYS/exe/run:
    /home/db2inst1/sqllib/lib64]
    when i acess the application url next time it gives me
    Application error occurred during request processing.
      Details:   java.lang.NoClassDefFoundError: com.sap.mw.jco.JCO (initialization failure)
    Exception id: [00145EB7604700720000000F000C20FE00047CA4F0EF0615]
    Below is my my javacode - I am calling the method getUserRoles
    package com.mysap.sso;
    import com.sap.mw.jco.*;
    import java.util.ArrayList;
    import java.util.List;
    public class BapiConnection {
         private static JCO.Client mConnection;
         private static JCO.Repository mRepository;
         private static JCO.Function createFunction(String functionName)
                   throws Exception {
              try {
                   IFunctionTemplate ft = mRepository.getFunctionTemplate(functionName
                             .toUpperCase());
                   if (ft == null) {
                        return null;
                   } else {
                        return ft.getFunction();
              } catch (Exception ex) {
                   throw ex;
         public List getUserRoles(String user) {
              JCO.Function function = null;
              JCO.Table activitygroups = null;
              List rolesList = null;
              mConnection = null;
              mRepository = null;
              mConnection = JCO.createClient("300", "INVTRY_SEGMT", "Welcome%1",
                        null, "ade00fe", "22");
              try {
                   //Connect to the WebAS ABAP with the parameters above
                   mConnection.connect();
                   //Create a function repository to be able to build a function
                   mRepository = new JCO.Repository("INVTRY_SEGMT", mConnection);
                   //Get the function
                   function = createFunction("BAPI_USER_GET_DETAIL");
                   //Set the only import parameter
                   function.getImportParameterList().setValue(user, "USERNAME");
                   //Execute the function
                   mConnection.execute(function);
                   //Get the 'ADDRESS' return structure
                   activitygroups = function.getTableParameterList().getTable(
                             "ACTIVITYGROUPS");
                   rolesList = new ArrayList();
                   for (int i = 0; i < activitygroups.getNumRows(); i++, activitygroups
                             .nextRow()) {
                        System.out.println(activitygroups.getString("AGR_NAME"));
                        logger.debug(activitygroups.getString("AGR_NAME"));
                        rolesList.add(activitygroups.getString("AGR_NAME"));
                   mConnection.disconnect();
              } catch (Exception ex) {
                   System.err.println(ex.toString());
              return rolesList;

  • OS level calls in Java.. example.

    Simple and perhaps idiotic question... but here it goes.
    Is there a way to make OS level calls in Java (i.e such as the cp, mv or ls/dir commands)?
    What class due I need to instantiate do to this? and is it the same for UNIX and win32 systems?
    Here is what I attempted to do:
    ================
    import java.io.*;
    public class Test {
    private static void main(String args[]) {
    String cmd[] =
    {"copy", "c:\\temp\\test.txt", "c:\\temp\\test2.txt"};
    try {
    Process p = Runtime.getRuntime().exec("copy test.txt test2.txt");
    p = Runtime.getRuntime().exec(cmd);
    } catch (Exception e) {
    e.printStackTrace();
    However, the above code results in the following error at runtime...
    =============
    java.io.IOException: CreateProcess: copy c:\temp\test.txt c:\temp\test2.txt error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:61)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:546)
    at java.lang.Runtime.exec(Runtime.java:413)
    at java.lang.Runtime.exec(Runtime.java:356)
    at java.lang.Runtime.exec(Runtime.java:320)
    at Test.main(Test.java:7)
    ==============
    Thoughts?
    Any help is greatly appreciated.
    Regards
    echardrd

    Almost right...
    "copy" is a shell builtin for Windows, so you need to call it as an argument to cmd.exe (or command.com on older systems). E.g. in Win2000 you can go:
    Runtime.getRuntime().exec( "cmd /c copy c:\\test1.txt c:\\test2.txt" );Where the /c is the parameter to tell cmd to carry out the given command. You could run this with the "start" command to push it into the background.
    Unix behaviour is roughly similar: cp is a Bash builtin for example, so you probably need to execute a shell process and pass it cp (I'm not sure about that one, I didn't test it)

  • OS level calls in Java?

    Simple and perhaps idiotic question... but here it goes.
    Is there a way to make OS level calls in Java (i.e such as the cp, mv or ls/dir commands)?
    What class due I need to instantiate do to this? and is it the same for UNIX and win32 systems?
    Any help is greatly appreciated.
    Regards
    echardrd

    Best place to look is exec() method of Runtime class.

  • Is there a way to make a video call from my iPhone 4 to a non apple phone? Also is it possible to transfer pics using bluetooth from iPhone to other company mobiles? Its a great phone but sometimes I feel struck inside it.

    Is there a way to make a video call from my iPhone 4 to a non apple phone? Also is it possible to transfer pics using bluetooth from iPhone to other company mobiles? Its a great phone but sometimes I feel struck inside it.

    You'd need an app like Skype to video call with other phones.
    Data transfer is not supported via bluetooth and iphone to iphone is not supported at all.

  • Is it possible to make an air application maximizable/non-maximizable programmatically at runtime?

    Is it possible to make an air application maximizable/non-maximizable programmatically at runtime?

    Sort of. Technically it's a NativeWindow which is maximizable or not, not the app itself. A NativeWindow is created as maximizable or not via NativeWindowInitOptions, and it can't be changed after it's created. Now, when you setup the "default content" window options with AIR, the runtime is basically creating the first window for you as a convenience, with those settings. However, there's nothing stopping you from making your initial content nothing more than a hidden window which will create a new window as maximizable or not. At this point, it would not be hard to re-create your main window with different maximizable values. (This is also how I implement multiple-instance/window apps, since only 1 AIR app can be running at a time.)
    Hope that helps!
    -Aaron

Maybe you are looking for

  • Changing to a solid state drive.. SSD

    I read a lot about the SSD's Has anyone changed out a regular HDD for a SSD? What kind.. WIll the Lenovo rescue disks install on to a SSD?

  • Payment lot (FP05) input text to FICA document

    Dear all, Is there any ways to input information in payment lot items and it pass to text field in each FICA document (table DFKKKO, DFKKOP, DFKKOPK)? Currently I can only input such information in usage text and it keep in table DFKKZP. Scenario: I

  • SSL Trust store (root CAs) for t3S client

    How does one set the root CAs trusted by the t3s client? The client requires that the server authenticate with a certificate signed by a "trusted CA" doesn't it? From what I'm seeing, it looks like maybe it doesn't. Am I missing something? Thanks in

  • Understanding point theme of dvt:map component

    for usage of point theme..we have to mention either latitude and longititude  or  address and city and country and postal code i want to know exactly what is latitude and longitude (these values varies if you use google maps and oracle maps ) and in

  • Getting Dates using combo boxes

    I am trying to get a start date and an end date from a combo box. I have the following AS3 code but it doesn't work. startDay, startMonth etc are all comboboxes with appropriate data. Just can't figure the syntax to make it work. var start_date = new