Thursday, February 17, 2011

java.lang.ClassFormatError: Truncated class file

Recently I kept getting this error when I copied over my .class files onto a remote server and attempted to run my java class on the server. I was using WinSCP to copy the files onto the server and the copy kept getting corrupted when I sent it across to the server. I shutdown WinSCP and started the process again which solved the problem.

Sunday, February 6, 2011

Programming NPV on Sharp EL-5250

Here is an example of how you can program your Sharp EL-5250 programmable calculator to calculate the NPV value when given yearly cash inflows.

Print"INITIAL CASH FLOW
Input C
Print "NO. OF YRS
Input N
Print"INTEREST
Rem IF I=12% NEED TO INPUT AS 0.12
Input I
Rem TIME COUNTER
T=1
Rem KEEPS THE CURRENT VALUE
X=0
Label CHECK
If T<=N Goto NPV
If T>N Goto THEEND
Label NPV
Print"NEXT CASH FLOW
Input F
X=X+(F/(1+I)^T)
T=T+1
Goto CHECK
Label THEEND
Rem NEED TO SUBTRACT INITIAL CASH FLOW
X=X-C
Rem X IS NOW THE NPV
Print X
End

Friday, February 4, 2011

Using ANT to create javadocs

Here is a very simple example to create javadocs using ANT. The fields should be replaced with your own parameters e.g. packagename should be replaced by the name of the package that contains the classes that you want to create javadocs for.

<target name="document">
  <javadoc destdir="doc" author="true" version="true" use="true" windowtitle="My JavaDocs">
    <fileset dir="src" defaultexcludes="yes">
      <include name="packagename/**">
      </include>

      <classpath>
        <fileset dir="lib">
          <include name="**/*.jar">           </include>
        </fileset>
        <doctitle><!--[CDATA[<h1>Mobile Text Adverts</h1>]]--></doctitle>
        <bottom><!--[CDATA[<i>Copyright &#169; 2011 Company Name. All Rights Reserved.</i>]]--></bottom>
      </classpath>

    </fileset>
  </javadoc>
</target>