Truncated class file !

Hi folks,
I've got a peculiar problem here :-( ...
I've got this Java code (that uses an external jar) that compiles fine. But whenever I try to run the code it gives me a truncated class file error. And I am getting this error only in Solaris and not in Windows !!!
Following is the trace that I am getting:
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:495)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:110)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$1(URLClassLoader.java:217)
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:192)
at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:290)
at java.lang.ClassLoader.loadClass(ClassLoader.java:256)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
Initially I thought that the class file might be broken. But even after numerous recompiling the problem is still persiisting :-(. Any idea fellas ?

BadCoder,
[Oh, wicked, bad naughty coder|http://www.sacred-texts.com/neu/mphg/mphg.htm#Scene%2011] (read it through then [consult the book of armaments|http://www.youtube.com/watch?v=xOrgLj9lOwk&feature=related]).
Any idea fellas ? Nope. Absolutely none. I have consulted the chicken entrails, and the news ain't good. Have you considered suicude?\
Yeah that might be overdoing things somewhat.
So what happens if you compile on Solaris. Are you using the exact same versions of javac and java on both machines? Do you have control over that? Hint: you can install whichever JVM you like on solaris, to your ~ without affecting other users... but "the" version tends to age somewhat, what with a 5 year MTBF and all.
Cheers. Keith.

Similar Messages

  • HELP!!! java.lang.ClassFormatError: (Truncated class file)

    Hello all,
    I'm writing a ClassLoader and the funniest things are happening. If I load a compiled class for the first time after compilation everything is ok. Once I change the class and recompile it, it starts putting out java.lang.ClassFormatError: (Truncated class file). If I alter the changes back to normal and recompile. It works again. Is there some sort of buffer which keeps the once loaded class in memory, even after rebooting?
    Please help, I'm at a loss
    Gideon

    hi dmbdmb,
    I got following error when try to run a java code in JBoss.
    15:39:56,696 ERROR [LogInterceptor] Unexpected Error:
    java.lang.ClassFormatError: Thilina (Truncated class file)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:448)
    at com.sun.tools.javac.v8.StringCompiler$Loader.findClass(StringCompiler
    .java:63)
    at com.sun.tools.javac.v8.StringCompiler.executeMethodWithReturnType(Str
    ingCompiler.java:120)
    at cc.aot.qVoice.domain.ejb.qVoiceManager.qVoiceManagerEJB.getVxmlString
    (qVoiceManagerEJB.java:125)
    I use JBoss 3.0.6 and sdk 1.4. In my program, classes are create and load on the fly. Then using Reflection API I called some
    methods in the dynamically created class(this class not
    write into a file and it is taken as a String variable).
    I refferd this url as a guid to write class loader and compiler.(actually same thing i copied
    from there and change it's name Pmat1 to StringCompiler)
    http://forum.java.sun.com/thread.jsp?thread=347467&forum=4&message=1439418
    When I run this as a normal application, it is work well. Then I try to run it in a jboss and it will give the above error.
    In here I Wote some EJBs and struts also and i called the methodds in the StringCompiler(Pamat1) class in a EJB. Thilina is
    the name of the dynamically created calss and StringCompiler is the class that includes the class loader and compiler methods
    as in the above url. qVoiceManagerEJB has a getvxmlString method. Whithin this method
    i called required the methods in the String compiler.
    Can u some body help me. Thanx in advanced for any help.
    anjithalb

  • Java.lang.ClassFormatError: Truncated class file

    Hi
    Previously my application is running on jdk 1.4 and its supporting castor i.e. castor-0.9.5.4-xml.jar
    Now i had upgrade my jdk to 1.6 and i am using same castor.jar
    so it is giving me following error
    Exception in thread "main" java.lang.ClassFormatError: Truncated class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
    at com.sun.tools.javac.v8.GenerateClass$Loader.findClass(GenerateClass.j
    ava:273)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.exolab.castor.mapping.loader.Types.typeFromName(Types.java:93)
    at org.exolab.castor.mapping.loader.MappingLoader.resolveType(MappingLoa
    der.java:228)
    at org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(Mappi
    ngLoader.java:394)
    at org.exolab.castor.xml.XMLMappingLoader.createDescriptor(XMLMappingLoa
    der.java:202)
    at org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoa
    der.java:258)
    at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:291)
    at org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:246)
    at org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:520)
    I also try to upgrade castor to latest version i.e castor1.2-xml.jar with jdk 1.6 and this time it gives me error
    Exception in thread "main" java.lang.ClassFormatError: Truncated class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
    at com.sun.tools.javac.v8.GenerateClass$Loader.findClass(GenerateClass.j
    ava:273)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.exolab.castor.mapping.loader.Types.typeFromName(Types.java:92)
    at org.exolab.castor.mapping.loader.AbstractMappingLoader.resolveType(Ab
    stractMappingLoader.java:384)
    at org.exolab.castor.xml.XMLMappingLoader.createClassDescriptor(XMLMappi
    ngLoader.java:209)
    at org.exolab.castor.mapping.loader.AbstractMappingLoader.createClassDes
    criptors(AbstractMappingLoader.java:262)
    at org.exolab.castor.xml.XMLMappingLoader.loadMapping(XMLMappingLoader.j
    ava:156)
    at org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmars
    haller.java:162)
    at org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmars
    haller.java:128)
    at org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:556)
    Can any one please help me out..
    Thanks in advance

    hi,
    i think one of application's class file currupted , Recompile all java files and then try.
    Edited by: sagar_birari on Mar 27, 2008 5:47 AM
    Edited by: sagar_birari on Mar 27, 2008 7:20 AM

  • Problem with:error: java.lang.ClassFormatError: Truncated class file

    Hello, I created an simple applet writing "hello world". Now I would like to add *.class file to my serwer witch I've implemented on microcontroller P89C51RD2BN.
    Serwer is programmed with hex file which is created after compiling C source files. In this case I converted .class file to array in C (using hexedit program). When I am (using IE ) browsing my serwer Html site is loading corectly and *.class file is send from serwer also corectly (define arrays are transfered corectly) but applet is not initiated. When I am runnig Java console I can see this:
    error: java.lang.ClassFormatError: Truncated class file
    When I am runnig the same site with the same class file on my PC everything is ok.
    I would be greatfull for any help. Thx. (sorry for my English :P )

    Not too familiar with native compilation, which I believe you are trying to accomplish here. It would appear that you don't have any problems running your applet, more or less running it after being converted to legacy code. Try the "native methods" forum under "Fundementals/Key Classes", this may be helpful. Sorry for not being too helpful.

  • Java.lang.AssertionError: WSDL not found in the class file "processes

    Hi,
    I am using WLI 10.3 workshop to build process application. I have designed one JPD which inturn call another process JPD. So i have used worklist process control to create the process and tried to access the process. When i am executing the code, i am getting below error message.
    13-Jun-2011 14:13:00 o'clock BST> <Error> <WLI> <BEA-000000> <Exception processing processes.ISPSSQMsgLisnt
    Java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.bea.wli.knex.runtime.core.dispatcher.DispUnit.loadDispFile(DispUnit.java:219)
    Truncated. see log file for complete stacktrace
    Java.lang.AssertionError: WSDL not found in the class file "processes.ISPSSQMsgLisnt", annotated class = processes.ISPSSQMsgLisnt
    --ClassAnnotations:
    --Method Annotations:
    --Field Annotations:
    can't continue
    at com.bea.wli.knex.runtime.jws.dispatcher.JwsDispClass.<init>(JwsDispClass.java:392)
    at com.bea.wli.bpm.runtime.JpdDispClass.<init>(JpdDispClass.java:65)
    at com.bea.wli.bpm.runtime.JpdDispClass.<init>(JpdDispClass.java:55)
    at com.bea.wli.bpm.runtime.JpdDispFile.createPrimaryDispClass(JpdDispFile.java:382)
    at com.bea.wli.knex.runtime.core.dispatcher.DispFile.<init>(DispFile.java:154)
    Truncated. see log file for complete stacktrace
    xception processing processes.ISPSSQMsgLisnt
    ava.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.bea.wli.knex.runtime.core.dispatcher.DispUnit.loadDispFile(DispUnit.java:219)
    at com.bea.wli.knex.runtime.core.dispatcher.DispUnit.<init>(DispUnit.java:153)
    at com.bea.wli.knex.runtime.core.dispatcher.DispCache.ensureDispUnit(DispCache.java:628)
    at com.bea.wli.knex.runtime.core.dispatcher.DispCache.ensureDispUnitForURI(DispCache.java:1029)
    at com.bea.wli.knex.runtime.core.dispatcher.DispCache.ensureDispUnitForURI(DispCache.java:950)
    at com.bea.wli.broker.JWSSubscriber.getDispClass(JWSSubscriber.java:231)
    at com.bea.wli.broker.JWSSubscriber.getRequest(JWSSubscriber.java:184)
    at com.bea.wli.broker.JWSSubscriber.doDispatch(JWSSubscriber.java:358)
    at com.bea.wli.broker.JWSSubscriber.doDispatch(JWSSubscriber.java:348)
    at com.bea.wli.broker.SubscriptionDispatcher.doDispatch(SubscriptionDispatcher.java:87)
    at com.bea.wli.broker.MessageBroker$PrivilegedSubscriptionDispatcher.run(MessageBroker.java:179)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at com.bea.wli.security.authentication.AuthenticationService.runAs(AuthenticationService.java:108)
    at com.bea.wli.broker.MsgBrokerSecurityHelper.doDispatch(MsgBrokerSecurityHelper.java:231)
    at com.bea.wli.broker.MessageBroker$PrivilegedSubscriptionDispatcher.doDispatch(MessageBroker.java:165)
    at com.bea.wli.broker.MessageBroker.publishMessage(MessageBroker.java:984)
    at com.bea.wli.mbconnector.jms.JmsConnMDB.publishMBMessage(JmsConnMDB.java:343)
    at com.bea.wli.mbconnector.jms.JmsConnMDB.onMessage(JmsConnMDB.java:475)
    at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
    at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
    at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
    at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
    at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    aused by: java.lang.AssertionError: WSDL not found in the class file "processes.ISPSSQMsgLisnt", annotated class = processes.ISPSSQMsgLisnt
    --ClassAnnotations:
    --Method Annotations:
    --Field Annotations:
    can't continue
    at com.bea.wli.knex.runtime.jws.dispatcher.JwsDispClass.<init>(JwsDispClass.java:392)
    at com.bea.wli.bpm.runtime.JpdDispClass.<init>(JpdDispClass.java:65)
    at com.bea.wli.bpm.runtime.JpdDispClass.<init>(JpdDispClass.java:55)
    at com.bea.wli.bpm.runtime.JpdDispFile.createPrimaryDispClass(JpdDispFile.java:382)
    at com.bea.wli.knex.runtime.core.dispatcher.DispFile.<init>(DispFile.java:154)
    at com.bea.wli.knex.runtime.jws.dispatcher.JwsDispFile.<init>(JwsDispFile.java:24)
    at com.bea.wli.bpm.runtime.JpdDispFile.<init>(JpdDispFile.java:108)
    ... 34 more

    Hi
    Are you using wli process control?
    That uses wsdl and could cause the issue.
    I also saw couple of internal bugs CR264315 and CR288904 on the same issue on 9.2.
    Since this is a wli issue could you post in the wli newsgroup to get more answers http://forums.bea.com/forum.jspa?forumID=2047 ?
    Also you can open a BEA support case at http://support.bea.com and an wli support engineer would help you. Please refer to the Cr numbers above in your support case.
    Thanks
    Vimala

  • Updating class file in deployed application in integrated Weblogic of Jdev

    Dear all,
    The Jdeveloper I'm using is version : 11.1.2.1.0
    When I deployed an application and then change the '.jspx' content and save, it will update the file in the deployed application in the integrated weblogic and everything works fine. (I can see the updated immediately without undeploy/deploy the application). When I updated a .java file, after compiling, it will shown the same message saying that the application on the integrated weblogic server is updated too, however, when I try clicking the page, it will show null pointer exception.
    Just hope to ask if manually undeploy/deploy the whole application is needed after updating a .java (class) file or it's just some configuration issue?
    Thanks a lot!
    Andrew

    Hi,
    I've tried to rebuild the whole working space but the exceptions are still exist. The error messages are pasted below for reference.
    So to get the udpated .java (class) to work, I need to 'manually' click on the 'run' command to the task flow file and a 'undeploy -> deploy' process will be done by the jdeveloper (need to wait for a few minutes).
    If no need to (undeploy->deploy), I think I can save many time a day. Anyway, Thanks for all repiles!
    Andrew
    Error Message:
    [05:52:06 PM] Updated /C:/Users/second52/AppData/Roaming/JDeveloper/system11.1.2.1.38.60.81/o.j2ee/drs/TRS_WEB/ViewControllerWebApp.war/WEB-INF/classes
    <ConfigureListener> <contextInitialized> Initializing Mojarra 2.0.5 (FCS b02) for context '/TRS'
    <Feb 22, 2012 5:52:40 PM HKT> <Error> <HTTP> <BEA-101020> <[ServletContext@17528203[app:TRS_WEB module:TRS path:/TRS spec-version:2.5]] Servlet failed with Exception
    java.lang.ClassCastException: oracle.adfinternal.view.faces.webapp.rich.RichWindowManagerFactory$WindowIdProviderAdapter cannot be cast to org.apache.myfaces.trinidad.event.WindowLifecycleListener
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManagerFactory$ApplicationWindowListeners.processWindowLifecylce(RichWindowManagerFactory.java:244)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager._fireWindowLifecycleEvent(RichWindowManager.java:496)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager._handleWindowOpened(RichWindowManager.java:539)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager.renderLoopbackPage(RichWindowManager.java:946)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:110)
         Truncated. see log file for complete stacktrace
    >
    <Feb 22, 2012 5:52:40 PM HKT> <Notice> <Diagnostics> <BEA-320068> <Watch 'UncheckedException' with severity 'Notice' on server 'DefaultServer' has triggered at Feb 22, 2012 5:52:40 PM HKT. Notification details:
    WatchRuleType: Log
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
    WatchData: DATE = Feb 22, 2012 5:52:40 PM HKT SERVER = DefaultServer MESSAGE = [ServletContext@17528203[app:TRS_WEB module:TRS path:/TRS spec-version:2.5]] Servlet failed with Exception
    java.lang.ClassCastException: oracle.adfinternal.view.faces.webapp.rich.RichWindowManagerFactory$WindowIdProviderAdapter cannot be cast to org.apache.myfaces.trinidad.event.WindowLifecycleListener
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManagerFactory$ApplicationWindowListeners.processWindowLifecylce(RichWindowManagerFactory.java:244)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager._fireWindowLifecycleEvent(RichWindowManager.java:496)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager._handleWindowOpened(RichWindowManager.java:539)
         at oracle.adfinternal.view.faces.webapp.rich.RichWindowManager.renderLoopbackPage(RichWindowManager.java:946)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:110)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101020 MACHINE = trsenh01 TXID = CONTEXTID = ca100e6c7f7fafe1:-4db71864:135a424c0e1:-8000-00000000000000ce TIMESTAMP = 1329904360140
    WatchAlarmType: AutomaticReset
    WatchAlarmResetPeriod: 30000
    >

  • Truncating a file in java?

    Hi,
    I am getting a problem while truncation the file.
    I wrote a file containing 100 doubles values and want to truncate the file to say 90 double values only. But after truncating i see that nothing is left in the file.
    I am writing into network drive.
    >>
    public class Test
    public static void main(String[] args)
    throws Exception
    String file = "/data/srq-nb/scratch/file";
    final long truncl = 90;
    final long length = 100;
    System.out.println("Writing ..");
    final FileOutputStream fos = new FileOutputStream(file);
    final BufferedOutputStream bos = new BufferedOutputStream(fos);
    final DataOutputStream dos = new DataOutputStream(bos);
    for(long i = 0; i < length; i++) {
    dos.writeDouble(i);
    dos.close();
    System.out.println("B4 Truncating" + new File(file).length());
    FileOutputStream fost = new FileOutputStream(file);
    fost.getChannel().truncate(truncl);
    fost.close();
    System.out.println("After Truncating" + new File(file).length());
    >>
    Output
    >>
    Writing ..
    B4 Truncating 80000000
    After Truncating 0
    Thanks
    D. L. Kumar

    D_L_Kumar wrote:
    FileOutputStream fost = new FileOutputStream(file);Read the API documentation for the FileOutputStream and see what it does (hint: it clears out any previous content).
    kind regards,
    Jos

  • How to convert class file

    Hi all, I am new in java card development.
    This is my environment setting:
    @echo off
    set JC_HOME=C:\JavaCard\java_card_kit-2_2
    set JAVA_HOME=C:\j2sdk14103
    set PATH=.;%JC_HOME%\bin;%PATH%
    I have created the Wallet applet according to 'Zhiqun Chen" text book and named it WalletApp.java.
    I have compiled this file to a class file.
    This is where is I saved my file
    C:\JavaCard\java_card_kit-2_2\samples\src\com\sun\javacard\samples\WalletApp\WalletApp.java.
    But I don't really understand how to convert the class file.
    May I know what is this for?
    -out EXP JCA CAP
    -exportpath
    -applet 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1
    com.sun.javacard.samples.HelloWorld.HelloWorld
    com.sun.javacard.samples.HelloWorld
    0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1 1.0
    must save this in what file?
    I tried to type in the command line below (and the result):
    C:\JavaCard\java_card_kit-2_2\samples>converter -config scr\com\sun\javacard\sap
    les\Wallet\Wallet.opt
    error: file scr\com\sun\javacard\saples\Wallet\Wallet.opt could not be found
    Usage: converter <options> package_name package_aid major_version.minor_ver
    sion
    OR
    converter -config <filename>
    use file for all options and parameters to converter
    Where options include:
    -classdir <the root directory of the class hierarchy>
    set the root directory where the Converter
    will look for classes
    -i support the 32-bit integer type
    -exportpath <list of directories>
    list the root directories where the Converter
    will look for export files
    -exportmap use the token mapping from the pre-defined export
    file of the package being converted. The converter
    will look for the export file in the exportpath
    -applet <AID class_name>
    set the applet AID and the class that defines the
    install method for the applet
    -d <the root directory for output>
    -out [CAP] [EXP] [JCA]
    tell the Converter to output the CAP file,
    and/or the JCA file, and/or the export file
    -V, -version print the Converter version string
    -v, -verbose enable verbose output
    -help print out this message
    -nowarn instruct the Converter to not report warning messages
    -mask indicate this package is for mask, so restrictions on
    native methods are relaxed
    -debug enable generation of debugging information
    -nobanner suppress all standard output messages
    -noverify turn off verification. Verification is default
    *********************************************************May I know What is the correct command line to convert the class file and what must I do to before converting the class file?
    I saw some article saying we must use JDK1.3, is it a must?
    Your solution is highly appreciated.
    Thank you!

    Hi Ricardo,
    I saved the file below as WalletApp.opt in the directory of scr\com\sun\javacard\samples\WalletApp
    -out EXP JCA CAP
    -exportpath c:\javacard\java_card_kit-2_2\api_export_files
    -applet 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x2:0x1 WalletApp.WalletApp
    WalletApp 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x2 1.0
    But I still have the problem below:
    C:\JavaCard\java_card_kit-2_2\samples>converter -config scr\com\sun\javacard\sam
    ples\WalletApp\WalletApp.opt
    error: file scr\com\sun\javacard\samples\WalletApp\WalletApp.opt could not be fo
    und
    Usage: converter <options> package_name package_aid major_version.minor_ver
    sion
    OR
    converter -config <filename>
    May I know What's wrong with my command or file?
    Where can I download JDK because what I can find is J2SDK.
    Thank you!

  • Error while converting class file to exp and jca file

    error while converting *.class file to *.exp and *.jca file
    =====================================================================================================================
    linux-y60u:/home/admin/java_card_kit-2_2_1/samples/src # converter -exportpath "/home/admin/java_card_kit-2_2_1/lib/" com/sun/javacard/samples/HelloWorld 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b 1.0 -v -applet 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b:0x01 Identity
    Java Card 2.2.1 Class File Converter, Version 1.3
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    parsing /home/admin/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/HelloWorld/HelloWorld.class
    parsing /home/admin/java_card_kit-2_2_1/samples/src/com/sun/javacard/samples/HelloWorld/Identity.class
    error: com.sun.javacard.samples.HelloWorld.HelloWorld: unsupported class file format of version 50.0.
    error: com.sun.javacard.samples.HelloWorld.Identity: unsupported class file format of version 50.0.
    conversion completed with 2 errors and 0 warnings.
    =====================================================================================================================

    i compile a file javacard use this command:
    ===
    javac -source 1.3 -target 1.1 -g -classpath ./classes:../lib/api.jar:../lib/installer.jar src/com/sun/javacard/samples/Identity/Identity.java
    ===
    and try to convert this class use this command
    ===
    /home/xnuxerx/admin/java_card_kit-2_2_1/bin/converter -exportpath "/home/xnuxerx/admin/java_card_kit-2_2_1/lib/" com/sun/javacard/samples/Identity 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b 1.0 -v -applet 0x00:0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x0b:0x01 Identity
    ===
    result convert:
    ===
    Java Card 2.2.1 Class File Converter, Version 1.3
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
    parsing /home/xnuxerx/admin/java_card_kit-2_2_1/samples/classes/com/sun/javacard/samples/Identity/Identity.class
    converting com.sun.javacard.samples.Identity.Identity
    error: export file framework.exp of package javacard.framework not found.
    conversion completed with 1 errors and 0 warnings.
    ===
    why ??
    please your comment for this problem.
    thank 4 all.

  • NetBeans IDE 4.1 & a class file

    Hello, I use NetBeans IDE 4.1 to write my java programs. I've been assigned to write a program that will prompt the user for an input. To make this easier, my University has written a file called "In.java" so we can easily get any type of input from the user. For example if we want the user to enter his/her name, we would write:
    System.out.println ("Please enter your name: ");
    String name = In.getString(); //allows user to enter a string
    The "In.java" file is supposed to be kept and compiled in the directory I'm working in. I kept it in C:\j2sdk1.4.2_09 and it works fine when I write a program in notepad but not NetBeans IDE. It does not recognize the "In.class" file. Any way to get around this? Thanks in advance.

    NetBeans 4.1 is bundled with J2sdk1.5.0_04. Check your NetBeans classpath and see if it is pointing to the newer sdk.
    If so, it needs to be changed to point to your older SDK...
    ... or, get your In.class file into the current NetBeans classpath...
    ... or read up on, and use the new Scanner class in the new sdk.

  • JavaCompiler outputs .class files in wrong folder

    I'm trying to compile some code using the Compiler API. The code belongs to package "compile", however, upon compiling the code, the class file ends up in the root directory rather than in the "compile" folder as I was expecting. The compiler seems to be ignoring the package info. What am I doing wrong here?
    package compile;
    import java.io.IOException;
    import java.net.URI;
    import java.util.Arrays;
    import javax.tools.*;
    import javax.tools.JavaCompiler.CompilationTask;
    public class CompilerTest {
         private static final String code =
              "package compile;\n" +
              "class TestClass {\n" +
              "     public static void main(String[] args) {\n" +
              "          System.out.println(\"Hello World!\");\n" +
              "     }\n" +
              "}\n";
         public static void main(String[] args) {
              JavaStringObject source = new JavaStringObject("compile.TestClass", code);
              Iterable<? extends JavaFileObject> sources = Arrays.asList( source );
              JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
              CompilationTask task = compiler.getTask(null, null, null, null, null, sources);
              System.out.println( task.call() );
         /** Java source from a String */
         private static class JavaStringObject extends SimpleJavaFileObject {
              private final String code;
              public JavaStringObject(String className, String content) {
                   super( URI.create("string:///"+className.replace('.','/')+Kind.SOURCE.extension), Kind.SOURCE );
                   code = content;
              public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
                   return code;
    }Thanks

    How do we know it is wrong?
    You are not showing where you compile and run this from.
    Also you are making it more confusing than it needs to be because your test class and the data for the compilation have the same package - I'd put CompilerTest and TestClass into different packages just to remove the potential for confusion.
    You are not specifying a -d option to the compiler.
    You are not specifying what the working directory is and the classpath when you run your test.
    You are not telling us where the generated class file is placed.
    When you say root directory do you mean the file system root, or the working directory or what?
    With some more information we might be able to either reproduce your fault or alternatively explain to you why what you are observing is the expected behaviour.
    Bruce

  • Importing my class files from another folder

    hello everybody ,im creating a software package for a new company and want to organise my class files into different folders so that it would be easier for someone to navigate through them and update if necessary ,how do i import an instance of a class in a file that is in a subfolder of the folder that contains the class that is calling it.(sorry for being a bit long winded) iv tried diff things and they didn't work.
    At the moment i have all the files in the one folder,but as i said above want to put them into appropriate folders.
    I would be very gratefull if someone could give me some examples and if not some appropriate links,thanks iv tried looking for this on the net but could not find anything.

    What you should probably do is to organise your classes into a heirarchy of packages not merely folders. Java expects the package structure to be reflected in the directory structure holding both the source and class files. If it's looking for a class called, say, com.mycompany.widgets.MainWidget it expects to find it in a directory com//mycompany/widgets relative the the directory on the class path.
    Use the package directive in each source file to indicate the package path.

  • Adding .class files to your project and making them work.

    Ok, im fairly new to java and having trouble understanding how to make importing of .class files work. Im using eclipse 3.2
    I have the files in a directory and I have gone to project->properties->java build path->libraries->add external class folder and pointed it to the correct place.
    Now, I am trying to use some of the classes it provides. I get no errors when creating the object with this code:
    com.ECS.client.jax.ItemSearchRequest itemRequest = new com.ECS.client.jax.ItemSearchRequest();
    Before I did the add external class folder that code would error cause it didnt know what com.ECS was. Now it works fine. My problem is that when I try to use a class, it does not recognize it as a class. After doing the above code I have:
    itemRequest.setSearchIndex("Books");
    its giving me an error on the period, saying: "Syntax error on token(s), misplaced construct(s)". Its not seeing that it is a class, so I can't use it. But when I am creating the object I get no errors. For reference, here is the chunk of code:
    com.ECS.client.jax.ItemSearchRequest itemRequest = new com.ECS.client.jax.ItemSearchRequest();
    itemRequest.setSearchIndex("Books");
    the second line of which errors. So my question is, how do I get it to recognize that the itemRequest is a class when I have imported the .class files to my project already?

    It's working fine. It's just that you have to put your code in a method.

  • Problem with variable in class file.

    Im working on a project from school where I read in a text file with numbers and print the max and the min. In my main file, I read in the text file and set the different numbers to variables a, b, and c. My question is, when Im writing my class file MaxMin, is there anyway to access those variables to compare them? Or will I have to do it some other way. Thanks for your help.

    Ok. Sorry
    Here is the main code
    import java.io.*;
    import java.util.StringTokenizer;
    public class LabAssign1
    public static void main(String[] args) throws IOException
    final int TOKENS_PER_LINE = 3;
    String fileName = "labassign1.txt";
    File theFile = new File(fileName);
    FileInputStream theStream = new FileInputStream(theFile);
    InputStreamReader theReader = new InputStreamReader(theStream);
    BufferedReader input = new BufferedReader(theReader);
    int numLines = 0;
    String line = input.readLine();
    while (line != null)
    StringTokenizer st = new StringTokenizer(line);
    if (line.length() == 3)
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    int c = Integer.parseInt(st.nextToken());
    else
    line = input.readLine();
    input.close();
    Is there any way to call variables a,b,and c in a separate class file?

  • How to edit a ".class" file?  Anyone?

    I hope someone can help me with this...
    Someone gave me a class file to put into my applet. However, I'm wanting to go into the class file and change a few things around. However, I've done just about everything to try to find a way to go into the code of this file to do some changing, and I can't find anything to do it with! I've tried Netbeans and Visual Studio .NET, but it doesn't work. Maybe I'm doing something wrong. Does anyone know how to go into the class file and change it?
    thanks soo much..

    Someone gave me a class file to put into my applet.
    ... Does anyone know how to go
    into the class file and change it? And why can't you ask "someone" for the source? Or ask them to modify it for you?

Maybe you are looking for

  • Blocking internet access in a virtual windows xp box

    Is there a way to block internet access when I have a virtual windows xp box within Windows 7? The reason, is I just want to run one application and restrict internet access as I some users are restricted from the internet. Thanks John

  • Help with phone problem

    I'm in the UK and I'm on the Orange network. I have a Curve 8900 and have had it for a year and a half. My problem is that I had to redownload the BlackBerry AppWorld because mine wasn't working, yet when I tried to reboot it after downloading it, as

  • How Do I Revert Back to The Old Version?

    Dead tired last night I automatically clicked "Install" when I saw the Safari download in updates thinking it was just the usual security fix, etc. Later when I launched Safari to get on the net I was horrified to see a whole new interface! As the ow

  • RDBMS Synchronization problem in ACS Appliance 3.3

    Hi, I was adding multiple AAA Clients on ACS Appliance using RDBMS Synchronization option I followed the complete steps but failed to synchronize accountActions.csv file on ACS my ftp server is working fine and returned the logs saying "accountAction

  • F4 - Help CRMM_BUPA_SEARCH - Favorite list

    Hi SDN, I've got a question and hope you can give me the answer: We are using the BSP Application CRMM_BUPA_SEARCH for the search help functionality in the BSP Application CRMD_SALQ on field Sold_to_Party_List... The problem is that our users create