NoSuchMethodError compiling with 1.4 and running on 1.3

Hi community,
I have a little problem with code like the following when mixing both JDK versions:
StringBuffer sb1 = new StringBuffer();
sb1.append(new StringBuffer());In 1.3 this is linked to append(Object) and in 1.4 to the newly added append(StringBuffer) which does not exist in 1.3. The code compiles fine with both versions, but if compiled under 1.4 and run in 1.3 this throws NoSuchMethodError(as it should, of course).
I understand why it is so, the question is if there is an easy way to overcome this problem. I played with the target option of javac without success(javap shows it is always linked as stated), also I read a bit in the JLS to make sure I am right why the exception is thrown.
I see the following choices:
1. Compile with 1.3. Not a good idea because all other our products are developed and run in 1.4;
2. Ask the customers to upgrade to 1.4. There is some their reason for which they still stick to 1.3 and don't want to upgrade, we can't force them do it;
3. Find such places in code and explicitly cast. But who will know what other cases like the above exist in the code. I can find where append(StringBuffer) is used in the code, but what about other methods of other JDK classes? And it is a bad idea because somewhere in time it will anyway run with 1.4.
My question is if there is another easier option that I am missing at the moment.
Thanks for you time and cooperation
Mike

Why is option 1 bad? You will be able to run it in 1.4 even if you compiled it using 1.3, so I don't see the problem? It will never run in 1.3 if you can't compile it in 1.3.Because it will always be a source of errors. Always there will be someone that will not set up their project to use 1.3 for compile or will deconfigure it while working with the other projects. Besides that as I stated source compiles fine in both versions, I don't have a compiletime problem, but a runtime one.
I know this is the most reasonable option, I know what I would choose among the three listed above, I needed some confirmation if I have missed an option.
and you are correct about the target flagI only mentioned the target tag just as one of the directions of my search, we always whine for others not putting effort in their problems ;)
Thanks for opinions
Mike

Similar Messages

  • Question on model crashes (compiled with Matlab 2013b and Veristand 2013)

    These models were compiled with Matlab 2010a and Veristand 2010 and when I deploy them to RT target with Veristand 2013, everything works correctly.
    Now I compiled the same models with Matlab 2013b and Veristand 2013...they are successfully deployed to the same RT target but when I start the model (set model command to 0), the RT side crashes.
    The strange thing is that I found if I set the initial state of model to running, this crash won't happen but when setting initial state to paused then manually set model command to 0, RT machine crashes immediately. Have any one come across the similar issue? I feel it's something to do with the initial condition but wonder why it doesn't happen when compiled with Matlab 2010a and Veristand 2010. 

    That behavior definitely sounds odd. I would expect models that worlk in previous versions of VeriStand to work with newer ones as well.
    With that said several other things have changed in the interum between VeriStand 2010 and VeriStand 2013.
    I see you have already contacted us through a service request, we will continue troubleshooting there for the moment.
    Craig H. | CLA | Systems Engineer | National Instruments

  • How to compile other java files and run them from my own programs?

    I'm developing a unit testing tool for AspectJ, which can originally generate the stubs for aspect unit to be tested. All these stubs are java files. After generation of stubs, how can I program the code to compile this unit together with these stubs, i.e. how can I put the functionality of compilation and run, e.g. command "javac *.java" and "java *", into my own code.
    Hope you can understand what I mean.
    Thank you in advance.

    When I use Runtime.getRuntime().exec(command) for executing the AspectJ compile command "ajc", "IOException createProcess error=2" always occurs, while it is ok for Java comiple command "javac".
    Why this happens when I use Runtime.getRuntime().exec("ajc Hello.java Test.aj")? Is it the reason that Runtime.exec(String) may not support any command in DOS?
    (ajc is the compile command for the java file and aj file.)
    Thank you in advance.

  • Compiled with 1.5 and ran on 1.4

    I compiled a program with Java 1.5, and when I ran it on an environment running Java 1.4 it gives me
    java.lang.UnsupportedClassVersionError
    What's the cause of this issue? And why can't it backward-compatible?
    Is there a way to find out which version of Java a .class file is compiled with?

    Is there a way to find out which version of Java a
    .class file is compiled with?P.S. Yes, the version is encoded in the java class file. You can inspect the file using a hex editor, or write a program to dump them out (should be pretty simple).
    See http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html (specifically, minor_version, major_version). Note that the version number coded here is something other than 1.4, 1.5, etc... so you need to locate a reference which describes how these values correspond to actual JDK version numbers.

  • Applet compiled with 1.4 not running in IE 6

    I have a java applet when compiled with the 1.3 java sdk that came Oracle, runs correctly in IE 6. The applet opens a socket.
    When I compile it using 1.4 java sdk from sun and run it in IE 6 it does not work.
    When I installed the 1.4 SDK I selected to use it as IE's default java machine.
    Note if I look in the internet options, settings, view objects it shows the 1.4.1 jre twice.
    Note I can not remove the 1.3 jre that comes with Oracle as the installation is dependant on it.
    The java classes included in my applet is
    import java.net.*;
    import java.io.*;
    import java.text.*;
    import java.awt.*;
    import java.lang.Thread;
    import java.applet.*;
    I have the sdk bin directory early in the path and class path enviroment includes rt.jar from the 1.4 sdk.
    I have even been into the reg and edited IE's classpath.
    Anybody help, how do I know what jre, IE is using or why the applet won't run in IE6. Both versions run in Appletviewer.
    Once I get this working I want to add javax and org classes to start passing XML over the socket anybody got advise on this also.

    there are a couple of things to try with this. first is to try the class out with the java plugin enabled - this makes IE run the 1.4.1 VM, instead of the default 1.1 VM in IE. if this works, you probably have a version conflict in your code, and could try compiling with
    '-target 1.1'
    in your arguments. The problem I'm having is to do with finding the referenced classes in the applet. Try commenting EVERYTHING out of your applet (except 'init') and then running it. if the applet loads, the problem is that any class you try to instantiate inside the applet is not found by the browser. (NB you get the same error message with a version conflict as with a missing class file, very helpful...).
    I'm not on this list much so if you want to talk more, or if you've solved this problem, please email me at [email protected]
    String signoff = "thanks in advance for any help" OR "hope this helped"

  • Problem with Nike plus and running in non-Nike sneakers

    I love running with my Nike plus and my itouch, but I've been having trouble with my Nike plus logging incorrect mileage when I attach the foot sensor to my non-Nike running shoes (in one of those little velcro pouches secured to the shoelaces). For instance, I ran a half marathon and it logged 4 miles. When I put the sensor back in my Nike plus shoes (which aren't quite as comfortable for me) everything is fine. Is anyone else having this problem? Should I carve a hole in the insole of my other sneakers to embed the sensor?

    Seems something got corrupted with this VI. Copy things over to a fresh VI and things should be OK.
    See also this recent report of a similar issue.
    LabVIEW Champion . Do more with less code and in less time .

  • Compiling form on Windows2000 and running on XP

    We have compiled forms on Window2000 forms6.08.22.1 and running on windows XP, occasionally forms are freezing up on XP, has anybody faced similar situation?
    thanks

    Yes we are using patch 13. (6.0.8.22.1)

  • Compile with 1.5.0 Run with 1.4.2 issue

    Hi All
    I compiled code with J2SDK 1.5.0 (or whatever it's called now) I then tried to run it on a JRE version 1.4.2.
    It would not run, a long list of errors appeared.
    Is it normal for this to happen?
    To investigate I compiled the code with JSDK 1.4.2, that ran with no problems.
    Any input appreciated
    Thanks

    Hi,
    or try the RetroWeaver-Tool. You can download here:
    http://retroweaver.sourceforge.net
    -Martin-The problem with using the 1.5 compiler and e.g. RetroWeaver is not the generated byte code. The problem is that the compiler might match certain methods calls to methods which are new to Java 1.5. E.g. the class BigInteger has a constructor which only is available in JDK 1.5.
    Kaj

  • Help with jar files and running them

    I have been trying to figure out how to run executable java files, now I have heard that a million and one people have asked this already. Though when I see the answer to these questions I am still quite confused, I would like to understand some things. First thing is how do you even save your java code as a jar file. Secondly, what is a jar file. Thirdly, I have seen many people talking about batch files, what are they? And finally, I have used many "wrappers" and I still cannot get it to work. Plz help

    A quick google search gave me [url http://neptune.netcomp.monash.edu.au/JavaHelp/howto/jar.htm]this website about jars.

  • Compiling a Cocoa program and run - crash at startup

    Hello there!
    I've got a really strange problem. I've got two different macs (an iMac late 2008 and a MacBook late 2008). I've got on both Mac OS X 10.6.2 and XCode 3.2.1.
    On both the macs I downloaded the same sources of an i386 application. On the MacBook it compiles fine (configuration Release/Debug Mac OS X 10.6 i386) and starts as well as expected. On the iMac I compile it fine but when I start it, it crashes.
    Here is the crash log... CoreFoundation is the thread that crashes. Any idea? I've tried to reinstall XCode and its components, to uninstall and reinstall it... dunno what's the difference between the two configurations! Without considering I formatted both before installing Snow Leopard just to start from scratch.
    Any hing? Thanks
    http://pastebin.com/m55a16428

    Thanks
    Dunno WHY, but on the iMac it was crashing due to that method... I created two NSString and simply deleted the name method... something like this:
    NSString *sBehavior = [[behaviorPopup selectedItem] representedObject];
    NSString *sRoute = [[routePopup selectedItem] representedObject];
    NSString *status = [NSString stringWithFormat: @"%@ (%@). ",sBehavior,sRoute];
    Now it works on both the macs

  • VSM-BC4J IN JDEV9042:compile error at JClient and run error at JSP

    compile error at JClient:
    C:\VSM-BC4J\src\oracle\otnsamples\vsm\client\admin\profilePanal.java
    --! Wraning(424,18):method setNextFocusableComponent(java.awt.Component) in class javax.swing.JComponent has been deprecated
    --! Wraning(425,20):method setNextFocusableComponent(java.awt.Component) in class javax.swing.JComponent has been deprecated
    --! Wraning(428,21):method setNextFocusableComponent(java.awt.Component) in class javax.swing.JComponent has been deprecated
    --! Wraning(430,13):method setNextFocusableComponent(java.awt.Component) in class javax.swing.JComponent has been deprecated
    run error at JSP:
    503 Service Unavailable
    Servlet error:Parsing error processing resource path

    Solution: don't use a runtime expression for the id attribute.
    The id attribute is used to declare
    - an attribute in scope
    - a scriptlet variable on the page
    These are only available for the duration of the <logic:iterate> tag
    The "id" is only used in your programming. You don't need to make it dynamic.

  • Problem with "Application lanucher and run as an system user

    Hi
    Im trying to distribute
    Application Lanucher NT Service was not found to run the application as system user.

    Mossbrant,
    > Im trying to distribute
    >
    > Application Lanucher NT Service was not found to run the application as
    > system user.
    >
    I guess this is a duplicate of the one below? I will anser that one.
    - Anders Gustafsson (Sysop)
    The Aaland Islands (N60 E20)
    Novell has a new enhancement request system,
    or what is now known as the requirement portal.
    If customers would like to give input in the upcoming
    releases of Novell products then they should go to
    http://www.novell.com/rms

  • My MBP just blacked off on the table with speakers connected and running

    Have bought a MBP in HKG exactly 1 year ago and is almost in a near new condition.It usually sits in a air con room and is not mishandled.Now when i was listening to songs on my external speakers and the power cable connected and showing green ,it just blacked out from everything to nothing.No charging light & cannot power up the system,It's like a dead machine.Couldn't figure out what happened.Kindly assist me to know the prob and as i am on a ship and will be going to singapore in few days ,what should i expect from the service center people? How much financial damage would be forced on me??
    cheers guys

    Try SMC and PRAM resets:
    http://support.apple.com/kb/ht3964
    http://support.apple.com/kb/ht1379
    If no success, bring the unit into a repair facility.  I do not believe that there are any APPLE stores as such in Singapore and you will be at the mercy of the resellers.
    Ciao.

  • Running a SSIS package with SQL Job and Linked Server

    I have a SSIS 2008 package. In one of the Script task I am calling a stored procedure which is  using Openquery using linked server. I deployed this package with protection level as "EncryptWithPassword" and gave a password to the package.
    Created a SQL job and edited its command line to include the password. If I login to SQL Server Mgmt Studio with Windows Authentication and run the job manually it runs fine. But when I schedule it then I get an error that "The Communication link to Linked
    server failed".
    Please help 

    Hi Vivek.B,
    The issue should occur because the SQL Server Agent Service Account or SQL Agent Proxy account under which the job step runs doesn’t have sufficient permissions on the linked server.
    If the job owner is the sysadmin fixed server role, the job can be run under the SQL Server Agent Service Account or a proxy account, then please make sure the SQL Agent Service Account or the proxy account has corresponding login on the linked server. If
    the job owner is not a sysadmin fixed server role, the job must run under a proxy account. In this case, make sure the proxy account has a corresponding login on the linked server.
    Reference:
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/10/13/who-owns-my-job-and-who-runs-it.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • I'm compiling with 1.5 but java is looking for 1.4 classes,why?

    Hello all,
    I need to compile my project with 1.5 and I have set everything correctly in my ant build script(I think) but I am getting the famous error:
    [javac] class file has wrong version 49.0, should be 48.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    I have been searching on Google for a couple of hours and read the whole thread on this that was locked. Most people with this error seem to want to compile with 1.4 but I'm compiling with 1.5 and for some reason it things I'm doing it with 1.4.
    If I do java -version i see 1.5, If I put -verbose when calling my build script I see 1.5 as the java version.
    I have tried with:
    jrockit_150_12
    jdk150_12

    jmejiaa wrote:
    Hello all,
    I need to compile my project with 1.5 and I have set everything correctly in my ant build script(I think) but I am getting the famous error:
    [javac] class file has wrong version 49.0, should be 48.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    I have been searching on Google for a couple of hours and read the whole thread on this that was locked. Most people with this error seem to want to compile with 1.4 but I'm compiling with 1.5 and for some reason it things I'm doing it with 1.4.
    Easiest explanation would be because you are.
    Actually that is the only explanation.
    If I do java -version i see 1.5, If I put -verbose when calling my build script I see 1.5 as the java version. You can find the 1.4 version and remove it or change the directory.
    One cause of this can because ant runs with a version but there are ways to make it use another one.
    And normally you don't run ant with java but rather via a script file and that specifies the java (for ant.)

Maybe you are looking for