Java.lang.Float

Is the function "public int compareTo(java.lang.Float)" defined in java.lang.Float overloaded with
"public int compareTo(java.lang.Object)"?
A javap of java.lang.Float shows that it is so,while the compiler has a different answer.With java version "1.4.2_08",the compareTo function accepts Object as an argument, but with java version "1.5.0_06" it throws the following warning:
LangTest.java:5: compareTo(java.lang.String) in java.lang.String cannot be applied to (java.lang.Object)This problem seems to exist for the compareTo function in all wrapper classes..

Is the function "public int
compareTo(java.lang.Float)" defined in
java.lang.Float overloaded with
"public int compareTo(java.lang.Object)"?
A javap of java.lang.Float shows that it is so,while
the compiler has a different answer.With java version
"1.4.2_08",the compareTo function accepts Object as
an argument, but with java version "1.5.0_06" it
throws the following warning:
LangTest.java:5: compareTo(java.lang.String) in
java.lang.String cannot be applied to
(java.lang.Object)This problem seems to exist for the compareTo
function in all wrapper classes..that's because Comparable has been made generic
so a String is not "just" a Comparable anymore, now it's a Comparable<String>

Similar Messages

  • Java.lang.NoSuchMethodError: java.lang.Float: method parseFloat(Ljava/lang/

    java.lang.NoSuchMethodError: java.lang.Float: method parseFloat(Ljava/lang/String;)F not found
    WHAT WOULD MAKE THIS HAPPEN. THIS SEEMS TO WORK IN JDK1.3.1 BUT NOT IN BLACKDOWN 1.1.3_V3
    THIS IS MY CODE:
    try{
    DecimalFormat dfp = new DecimalFormat( "0.00" );
    if(!Price.equals("")) {
    float MyFloat = Float.parseFloat(Price);
    Price = dfp.format(MyFloat);
    }catch(NumberFormatException nfe){
    PriceValid = 1;

    This error says:
    - There is no method called "parseFloat" that receives a String as parameter in class java.lang.Float.
    Look the method "parseFloat" at the class java.lang.Float!!

  • Using java.lang.Float.class causing Cannot format given Object as a Number

    hi,
    I have table and its model is default table model.
    model = new javax.swing.table.DefaultTableModel(data,col) {Class[] types = new Class [] {
                    java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Float.class,  java.lang.Integer.class
                }; public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }};I want to force the user to enter float number to fourth column and integer number to fifth column. but I am gettin an error "Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot format given Object as a Number" like this. cause of this error is "java.lang.Float.class". and when I use Integer instead of Float the is no problem. Could you please help ?

    It depends on model data.

  • Exception of type java.lang.UnsatisfiedLinkError was thrown Anyone ?

    We are getting this exception when trying to run a very basic aspx. This project works across several other servers, after bringing a new server online, we are finding we get this exception. Below is the complete response from tcptrace.
    HTTP/1.1 500 Internal Server ErrorServer: Microsoft-IIS/5.0Date: Tue, 24 Feb 2004 16:28:31 GMTX-Powered-By: ASP.NETX-AspNet-Version: 1.1.4322Cache-Control: privateContent-Type: text/html; charset=utf-8Content-Length: 5522
    <html> <head> <title>Exception of type java.lang.UnsatisfiedLinkError was thrown.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head>
    <body bgcolor="white">
    <span><H1>Server Error in '/PPAApps' Application.<hr width=100% size=1 color=silver></H1>
    <h2> <i>Exception of type java.lang.UnsatisfiedLinkError was thrown.</i> </h2></span>
    <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
    <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    <br><br>
    <b> Exception Details: </b>java.lang.UnsatisfiedLinkError: Exception of type java.lang.UnsatisfiedLinkError was thrown.<br><br>
    <b>Source Error:</b> <br><br>
    <table width=100% bgcolor="#ffffcc"> <tr> <td> <code>
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
    </td> </tr> </table>
    <br>
    <b>Stack Trace:</b> <br><br>
    <table width=100% bgcolor="#ffffcc"> <tr> <td> <code><pre>
    [UnsatisfiedLinkError: Exception of type java.lang.UnsatisfiedLinkError was thrown.] java.lang.ExceptionInInitializerError.checkAndThrowException(Throwable thrown) +59 java.util.Locale..cctor() +1678
    [TypeInitializationException: The type initializer for "java.util.Locale" threw an exception.] java.lang.Float..ctor(String s) +214 com.plumtree.remote.portlet.xp.XPSettingsManager.IsCSPVersionAtLeast(Double version) com.plumtree.remote.portlet.xp.XPSettingsManager..ctor(IXPRequest request, IXPResponse response) com.plumtree.remote.portlet.xp.XPSettingsFactory.getXPSettingsManager(IXPRequest request, IXPResponse response) com.plumtree.remote.portlet.xp.XPPortletContext..ctor(IXPRequest request, IXPResponse response) com.plumtree.remote.portlet.xp.XPPortletContextFactory.createPortletContext(IXPRequest req, IXPResponse resp) Plumtree.Remote.Portlet.PortletContextFactory.CreatePortletContext(HttpRequest req, HttpResponse resp) Com.Plumtree.Remote.Transformer.Condition.GatewayedStandardCondition.UseFilter(HttpContext ctx) Com.Plumtree.Remote.Transformer.FilterManager.UpdateFilter(HttpContext ctx) Com.Plumtree.Remote.Transformer.PTTransformer.BeginRequestHandler(Object sender, EventArgs e) System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87</pre></code>
    </td> </tr> </table>
    <br>
    <hr width=100% size=1 color=silver>
    <b>Version Information:</b> Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
    </font>
    </body></html><!-- [UnsatisfiedLinkError]: Exception of type java.lang.UnsatisfiedLinkError was thrown. at java.lang.ExceptionInInitializerError.checkAndThrowException(Throwable thrown) at java.util.Locale..cctor()[TypeInitializationException]: The type initializer for "java.util.Locale" threw an exception. at java.lang.Float..ctor(String s) at com.plumtree.remote.portlet.xp.XPSettingsManager.IsCSPVersionAtLeast(Double version) at com.plumtree.remote.portlet.xp.XPSettingsManager..ctor(IXPRequest request, IXPResponse response) at com.plumtree.remote.portlet.xp.XPSettingsFactory.getXPSettingsManager(IXPRequest request, IXPResponse response) at com.plumtree.remote.portlet.xp.XPPortletContext..ctor(IXPRequest request, IXPResponse response) at com.plumtree.remote.portlet.xp.XPPortletContextFactory.createPortletContext(IXPRequest req, IXPResponse resp) at Plumtree.Remote.Portlet.PortletContextFactory.CreatePortletContext(HttpRequest req, HttpResponse resp) at Com.Plumtree.Remote.Transformer.Condition.GatewayedStandardCondition.UseFilter(HttpContext ctx) at Com.Plumtree.Remote.Transformer.FilterManager.UpdateFilter(HttpContext ctx) at Com.Plumtree.Remote.Transformer.PTTransformer.BeginRequestHandler(Object sender, EventArgs e) at System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)-->HTTP/1.1 500 Internal Server ErrorServer: Microsoft-IIS/5.0Date: Tue, 24 Feb 2004 16:29:06 GMTX-Powered-By: ASP.NETX-AspNet-Version: 1.1.4322Cache-Control: privateContent-Type: text/html; charset=utf-8Content-Length: 5522
    <html> <head> <title>Exception of type java.lang.UnsatisfiedLinkError was thrown.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head>
    <body bgcolor="white">
    <span><H1>Server Error in '/PPAApps' Application.<hr width=100% size=1 color=silver></H1>
    <h2> <i>Exception of type java.lang.UnsatisfiedLinkError was thrown.</i> </h2></span>
    <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
    <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    <br><br>
    <b> Exception Details: </b>java.lang.UnsatisfiedLinkError: Exception of type java.lang.UnsatisfiedLinkError was thrown.<br><br>
    <b>Source Error:</b> <br><br>
    <table width=100% bgcolor="#ffffcc"> <tr> <td> <code>

    This is the response I got from support:
    This is bug 22205 and will be fixed in the release of the Exchange Groupware Portlet Suite 3.0.4 at the end of April. The workaround in the interim is to copy the D:\Program Files\plumtree\jre folder from the installation CD (or another working portal server) onto the problem server. Please let me know if this resolves the issue for you. Neal Rapoporthttp://www.portalconsultant.com

  • Java.lang.Throwable: method getCause()Ljava/lang/Throwable; not found in web-App

    Thanks for the answer, the problem is that for the first times that launch the application works in correct way in fact I see opened mine report to video, then stops to work and generates that error.

    This error says:
    - There is no method called "parseFloat" that receives a String as parameter in class java.lang.Float.
    Look the method "parseFloat" at the class java.lang.Float!!

  • Waiting on condition at java.lang.FloatingDecimal.floatValue(FloatingDecima

    Hello Experts,
    I am facing an issue while executing "floatValue" method of BIgdecimal Object.when the control comes to above method ,webdynpro application is going into infinite loop.this is working fine on all systems(development ,test..) except production.
    i found one difference in test and production system.Both are running on different java versions.is it causing this issue?
    test server is running on 1.4.2.17 and production is running on 1.4.2.12 version.
    here is the thread dump that i got in server:
    "SAPEngine_Application_Threadimpl:3_13ID#(J2EE25213200)D1139794350DB10384483039162372751End.6f1b61d0d00d11dcc73e001560dee930" tid=0x60000000037db8d0 nid=0x45 prio=10 waiting on condition
    at java.lang.FloatingDecimal.floatValue(FloatingDecimal.java:1710)
    at java.lang.Float.valueOf(Float.java:205)
    at java.math.BigDecimal.floatValue(BigDecimal.java:1012)
    at com.sap.xltest.components.mpfxl.xl.XLCust.mCreateXL(XLCust.java:787)
    at com.sap.xltest.components.mpfxl.xl.wdp.InternalXLCust.mCreateXL(InternalXLCust.java:306)
    at com.sap.xltest.components.mpfxl.MPFXLCompInterface.imCreateXL(MPFXLCompInterface.java:115)
    at com.sap.xltest.components.mpfxl.wdp.InternalMPFXLCompInterface.imCreateXL(InternalMPFXLCompInterface.java:296)
    at com.sap.xltest.components.mpfxl.wdp.InternalMPFXLCompInterface$External.imCreateXL(InternalMPFXLCompInterface.java:348)
    at com.pg.pftp.selectionscreen.views.selectionscreen.SelectionScreenView.onActionasimplDownload(SelectionScreenView.java:1395)
    at com.pg.pftp.selectionscreen.views.selectionscreen.wdp.InternalSelectionScreenView.wdInvokeEventHandler(InternalSelectionScreenView.java:731)
    at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
    at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)
    - locked<0x9fffffff3df65718> (a com.sap.tc.webdynpro.clientserver.cal.ClientApplication)
    at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
    at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
    - locked<0x9fffffff3e15de50> (a com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    any help will be greatly appriciated.
    Thanks in advance
    with regards,
    Balaram Naidu

    Hi,
    yes the version of java is the problem.you have to maintain samejava version in all server.if your version is same then there is no problem.

  • Waiting on condition at java.lang.FloatingDecimal.floatValue(FloatingDec.)

    Hello Experts,
    i am facing an issue while executing floatValue method of BIgdecimal Object.when the control comes to that statement ,application is going into infinite loop.this is working fine on all systems(development ,test..) except production.
    i found one difference in test and production system.both are running in different java versions.is it causing this issue?
    test server is running on 1.4.2.17 and production is running on 1.4.2.12 version.
    here is the thread dump that i got in server:
    D1139794350DB10384483039162372751End.6f1b61d0d00d11dcc73e001560dee930" tid=0x60000000037db8d0 nid=0x45 prio=10 waiting on condition
    at java.lang.FloatingDecimal.floatValue(FloatingDecimal.java:1710)
    at java.lang.Float.valueOf(Float.java:205)
    at java.math.BigDecimal.floatValue(BigDecimal.java:1012)
    at com.test.method(XLCust.java:787)
    at com.
    at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
    at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)
    - locked<0x9fffffff3df65718> (a com.sap.tc.webdynpro.clientserver.cal.ClientApplication)
    at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
    at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
    - locked<0x9fffffff3e15de50> (a com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
    at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    any help will be greatly appriciated.
    thanks in advance
    with regards
    Naidu

    Hi,
    yes the version of java is the problem.you have to maintain samejava version in all server.if your version is same then there is no problem.

  • Waiting on condition at at java.lang.FloatingDecimal.floatValue(FloatingDec

    Hello Experts,
    i am facing an issue while executing floatValue method of BIgdecimal Object.when the control comes to that statement ,application is going into infinite loop.this is working fine on all systems(development ,test..) except production.
    i found one difference in test and production system.both are running in different java versions.is it causing this issue?
    test server is running on 1.4.2.17 and production is running on 1.4.2.12 version.
    here is the thread dump that i got in server:
    D1139794350DB10384483039162372751End.6f1b61d0d00d11dcc73e001560dee930" tid=0x60000000037db8d0 nid=0x45 prio=10 waiting on condition
         at java.lang.FloatingDecimal.floatValue(FloatingDecimal.java:1710)
         at java.lang.Float.valueOf(Float.java:205)
         at java.math.BigDecimal.floatValue(BigDecimal.java:1012)
         at com.test.method(XLCust.java:787)
         at com.
         at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)
         - locked<0x9fffffff3df65718> (a com.sap.tc.webdynpro.clientserver.cal.ClientApplication)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
         - locked<0x9fffffff3e15de50> (a com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    any help will be greatly appriciated.
    thanks in advance
    with regards
    Naidu

    Hi,
    yes the version of java is the problem.you have to maintain samejava version in all server.if your version is same then there is no problem.

  • Error:  java/lang/String  & parsefloat not a method in class Float (j0235)

    Hi,
    I don't know why i amgetting this error which says: 'unable to locate system class: java/lang/String.
    I have compiled and executed the reader method separately on a command prompt and it is working, but when i do it in microsoft visual j++, i am getting this run time error.
    I also have rt.jar in the classpath.
    If i don't have this rt.jar in my classpath, it is giving me a compilation error: parsefloat is not a method in class Float (j0235).
    somebody please help.
    Jagadish.
    // an agent is floating randomly.
    import java.util.*;
    import vrml.*;
    import vrml.node.*;
    import vrml.field.*;
    import java.io.*;
    public class FloatingAgent extends Script{
    SFVec3f setAgentPosition;
    SFRotation setAgentRosition;
    static int count=0;
    float agentPosition[] = new float[3];
    float agentRosition[] = new float[4];
    float rotangle = 0.0f;
    float aRad= (float) (Math.PI/180);
    public void initialize(){
    setAgentPosition =
    (SFVec3f)getEventOut("setAgentPosition");
    setAgentRosition =
    (SFRotation)getEventOut("setAgentRosition");
    // initialize the agent position.
    agentPosition[0] = 0.0f;
    agentPosition[1] = 0.0f;
    agentPosition[2] = 0.0f;
    agentRosition[0] = 0.0f;
    agentRosition[1] = 0.0f;
    agentRosition[2] = 1.0f;
    agentRosition[3] = 0.0f;
    public void processEvent(Event e){
    if(e.getName().equals("interval") == true){
    moveAgent();
    void moveAgent()
    agentPosition = reader();
    rotangle += 2.0f;
    agentRosition[3] = rotangle * aRad;
    // move the agent to the new position.
    setAgentPosition.setValue(agentPosition);
    setAgentRosition.setValue(agentRosition);
    }//move agent
    static float[] reader()
    float p1[] = new float[3];
    try{
    FileReader fr = new FileReader("data.txt");
    BufferedReader br = new BufferedReader(fr);
    String s;
    int count1=0;
    count++;
    try{
    while((s=br.readLine())!=null)
    count1++;
    StringTokenizer st = new StringTokenizer(s);
    if(count1==count)
    int i=0;
    while(st.hasMoreTokens())
    p1[i++]=Float.parseFloat(st.nextToken());
    }//if
    }//end of stringTokenizer while.
    fr.close();
    catch(IOException f)
    System.out.println("file cannot be opened");
    }//try
    catch(FileNotFoundException e)
    System.out.println("file doesn't exist");
    } //try
    return p1;
    }//reader

    still using Visual J++ ???

  • Getting java.lang.NullpointerException while closing resultset aft using it

    Hi,
    I kindly request to share your ideas reg. my problem.
    I am opening a database connection using connection pool and i am using two or more resultsets and statement objects.I am closing these objects at the end of their usage.But i am getting java.lang.NullpointerException when i close them(if i don't close them it works fine). what might be the reason. Had i did any thing wrong in the code.
    please view the code
    public String storeNewConnection(String CIRCLE,String DIVISION,String SUB_DIVISION,String SECTION,String CONSUMER_NAME,String FATHER_NAME,String STREET_NAME,String DOOR_NO,String TOWN_CITY,String LAND_MARK,String PINCODE,String STDCODE,String PHONE_NO,String EMAIL,String NEIGHBOUR_SCNO,String DOCUMENT_CODE,String LT_APR_NO,String year1,String month1,String day1,String PCBNO,String CONSUMER_STATUS,String SOCIAL_GROUP,String CATEGORY_SUPPLY,String LOCATION_PREMISES,String PURPOSE_OF_SUPPLY,String DURATION,String LOAD_TYPE,String CONNECTED_LOAD,String CONTRACTED_LOAD,String APPLICATION_FEE,String DEVELOPMENT_CHARGES,String SECURITY_DEPOSIT,String ADDL_SECURITY_DESPOSIT,String DEPOSITED_THRU,String DD_CHEQUE_DETAILS,String year2,String month2,String day2,String REMARKS,String POLE_NO)
              int count=0;
              Statement st=null;
              ResultSet rs=null,rs1=null,rs2=null,rs3=null;
              PreparedStatement pst=null;
              String result="",query="",sysDate="",sysDate2="";
              String reg_no = "";
              try
                   st=con.createStatement();
                   //Check dates with sys date
                   String date1 =null;                    
                   String date2 =null;
                   if(! (year1.equals("") || month1.equals("") || day1.equals("")) )
                        date1=day1+"-"+month1+"-"+year1;
                        rs2=st.executeQuery("select round(to_date('"+date1+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
                        rs2.next();
                        if(rs2.getInt(1) != 0)
                             return "false";                              
                   if(! (year2.equals("") || month2.equals("") || day2.equals("")) )
                        date2=day2+"-"+month2+"-"+year2;
                        rs3=st.executeQuery("select round(to_date('"+date2+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
                        rs3.next();
                        if(rs3.getInt(1) != 0)
                             return "false";     
                   rs1=st.executeQuery("select to_char(sysdate,'yyyyMONdd'),to_char(sysdate,'dd-Mon-yyyy') from dual");
                   rs1.next();
                   sysDate=rs1.getString(1);
                   sysDate2=rs1.getString(2);
                   rs=st.executeQuery("select max(SERIAL_NO) from NEW_CONNECTIONS where to_char(sysdate,'yyyy') = to_char(REG_DATE,'yyyy') and to_char(sysdate,'mm') = to_char(REG_DATE,'mm') and SUB_DIVISION_CODE = "+SUB_DIVISION+" and DIVISION_CODE = "+DIVISION+" and CIRCLE_CODE = "+CIRCLE+" ");
                   if(rs.next())
                        count = rs.getInt(1);
                        count++;                              
                   else
                        count=1;
                   query="insert into NEW_CONNECTIONS ( "+
                        " REG_NO,SERIAL_NO,REG_DATE,CIRCLE_CODE,DIVISION_CODE,SUB_DIVISION_CODE,SECTION_CODE, "+
                        " CONSUMER_NAME,FATHER_NAME,STREET_NAME,DOOR_NO,TOWN_CITY,LAND_MARK,PINCODE, "+
                        " STDCODE,PHONE_NO,EMAIL,NEIGHBOUR_SCNO,DOCUMENT_CODE,LT_APR_NO,LT_APR_DATE, "+
                        " PCBNO,CONSUMER_STATUS,SOCIAL_GROUP,CATEGORY_SUPPLY,LOCATION_PREMISES,PURPOSE_OF_SUPPLY,"+
                        " DURATION,LOAD_TYPE,CONNECTED_LOAD,CONTRACTED_LOAD,APPLICATION_FEE,DEVELOPMENT_CHARGES, "+
                        " SECURITY_DEPOSIT,ADDL_SECURITY_DEPOSIT,DEPOSITED_THRU,DD_CHEQUE_DETAILS,DD_CHEQUE_DATE,REMARKS,APPLICATION_STATUS,POLE_NO) "+
                        " values(?,?,'"+sysDate2+"',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                   pst = con.prepareStatement(query);
                   String cnt ="";
                   if(count <= 9)
                        cnt="0000";
                   else if(count <= 99)
                        cnt="000";
                   else if(count <= 999)
                        cnt="00";
                   else if(count <= 9999)
                        cnt="0";
                   cnt+=Integer.toString(count);
                   reg_no = CIRCLE+DIVISION+SUB_DIVISION+SECTION+"N"+cnt+sysDate;               
                   int serial_no =count;
                   int pin = 0;
                   if(!PINCODE.equals(""))
                        pin =Integer.parseInt(PINCODE);
                   int std = 0;
                   if(!STDCODE.equals(""))
                        std = Integer.parseInt(STDCODE);
                   int status = Integer.parseInt(CONSUMER_STATUS);
                   int social_group = Integer.parseInt(SOCIAL_GROUP);
                   int supply = Integer.parseInt(CATEGORY_SUPPLY);
                   int location = Integer.parseInt(LOCATION_PREMISES);
                   int purpose = Integer.parseInt(PURPOSE_OF_SUPPLY);
                   int duration = Integer.parseInt(DURATION);
                   int laod_type = Integer.parseInt(LOAD_TYPE);
                   float conn_load = Float.parseFloat(CONNECTED_LOAD);
                   int cont_load = 0;
                   if(!CONTRACTED_LOAD.equals(""))
                        cont_load =Integer.parseInt(CONTRACTED_LOAD);
                   int app_fee = Integer.parseInt(APPLICATION_FEE);
                   int dev_chg = Integer.parseInt(DEVELOPMENT_CHARGES);
                   int sec_dep = Integer.parseInt(SECURITY_DEPOSIT);
                   int addl_sec_dep = 0;     
                   if(!ADDL_SECURITY_DESPOSIT.equals(""))
                        addl_sec_dep =Integer.parseInt(ADDL_SECURITY_DESPOSIT);
                   int dep_thru = Integer.parseInt(DEPOSITED_THRU);          
                   pst.setString(1,reg_no);
                   pst.setInt(2,serial_no);
                   pst.setString(3,CIRCLE);
                   pst.setString(4,DIVISION);
                   pst.setString(5,SUB_DIVISION);
                   pst.setString(6,SECTION);
                   pst.setString(7,CONSUMER_NAME);
                   pst.setString(8,FATHER_NAME);
                   pst.setString(9,STREET_NAME);
                   pst.setString(10,DOOR_NO);
                   pst.setString(11,TOWN_CITY);
                   pst.setString(12,LAND_MARK);
                   pst.setInt(13,pin);
                   pst.setInt(14,std);
                   pst.setString(15,PHONE_NO);
                   pst.setString(16,EMAIL);
                   pst.setString(17,NEIGHBOUR_SCNO);
                   pst.setString(18,DOCUMENT_CODE);
                   pst.setString(19,LT_APR_NO);
                   pst.setString(20,date1);
                   pst.setString(21,PCBNO);
                   pst.setInt(22,status);
                   pst.setInt(23,social_group);
                   pst.setInt(24,supply );
                   pst.setInt(25,location);
                   pst.setInt(26,purpose);
                   pst.setInt(27,duration);
                   pst.setInt(28,laod_type);
                   pst.setFloat(29,conn_load );
                   pst.setInt(30,cont_load);
                   pst.setInt(31,app_fee);
                   pst.setInt(32,dev_chg);
                   pst.setInt(33,sec_dep);
                   pst.setInt(34,addl_sec_dep);
                   pst.setInt(35,dep_thru );
                   pst.setString(36,DD_CHEQUE_DETAILS);
                   pst.setString(37,date2);
                   pst.setString(38,REMARKS);
                   pst.setInt(39,1);
                   pst.setString(40,POLE_NO);
                   pst.executeUpdate();
                   result=reg_no;                                   
                   rs.close();
                   rs=null;
                   rs1.close();
                   rs1=null;
                   rs2.close();
                   rs2=null;
                   rs3.close();
                   rs3=null;
                   st.close();
                   st=null;
                   pst.close();
                   pst=null;
              catch(Exception e)
                   e.printStackTrace();
                   result="false";
                   return result;
              finally
                   if (rs != null)
                        try
                             rs.close();
                        catch (SQLException e)
                        rs = null;
                   if (rs1 != null)
                        try
                             rs1.close();
                        catch (SQLException e)
                        rs1 = null;
                   if (rs2 != null)
                        try
                             rs2.close();
                        catch (SQLException e)
                        rs2 = null;
                   if (rs3 != null)
                        try
                             rs3.close();
                        catch (SQLException e)
                        rs3 = null;
                   if (st != null)
                        try
                             st.close();
                        catch (SQLException e)
                        st = null;
                   if (pst != null)
                        try
                             pst.close();
                        catch (SQLException e)
                        pst = null;
              return result;
    Also plz help me to improve the code if necessary so that it will work fine for multiple users
    thaks & regards
    Prasanth.C

    Thanks a lot.
    i replaced the code below
    if (rs != null)
                        try
                             rs.close();
                        catch (SQLException e)
                        rs = null;
                   if (rs1 != null)
                        try
                             rs1.close();
                        catch (SQLException e)
                        rs1 = null;
                   if (rs2 != null)
                        try
                             rs2.close();
                        catch (SQLException e)
                        rs2 = null;
                   if (rs3 != null)
                        try
                             rs3.close();
                        catch (SQLException e)
                        rs3 = null;
                   if (st != null)
                        try
                             st.close();
                        catch (SQLException e)
                        st = null;
                   if (pst != null)
                        try
                             pst.close();
                        catch (SQLException e)
                        pst = null;
    instead of blindly closing the resultsets and statements
    now it works fine.
    One more thing, is my code structurally correct, i mean the variables, try...catch blocks,results,statements,database connections and overall coding. whether it looks like professional code.
    thaks & regards,
    Prasanth.C

  • Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.dr

    Hi
    I am trying to use type 4 driver to connect to my Oracle 9i Rel2 database. I downloaded the odbc14.jar from oracle and added in the C:\Oracle9i\jdbc\lib path. As on the website, I setup my environment:
    Setting Up Your Environment
    On Win95/Win98/NT:
    - Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
    [ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x or 1.3 is
    used. Add ojdbc14.jar and nls_charset12.zip if JDK 1.4 is used.)
    - Make sure [ORACLE_HOME]\bin is in your PATH.
    Still I am getting the following error during runtime:
    Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at jdbc.InsertQueryEx.main(InsertQueryEx.java:11)
    Below is the source code:
    import java.sql.*;
    import java.io.*;
    public class InsertQueryEx {
    public static void main(String[] args)throws Exception{
    Class.forName("oracle.jdbc.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@Prashy:1521:orcl", "scott", "tiger");
    DataInputStream din = new DataInputStream(System.in);
    Statement stmt = con.createStatement();
    while(true){
    try{
    System.out.println("enter emp name");
    String name = din.readLine();
    System.out.println("enter emp no");
    int no = Integer.parseInt(din.readLine());
    System.out.println("enter emp salary");
    float sal = Float.parseFloat(din.readLine());
    System.out.println("enter emp address");
    String addr = din.readLine();
    int count = stmt.executeUpdate("insert into myemp values("+no+",'"+name+"',"+sal+",'"+addr+"')");
    if(count>0)
    System.out.println("Record added");
    else
    System.out.println("Failed");
    catch (Exception e){
    System.err.println("Exception: "+e.getMessage());
    Any help is appreciated
    Thanks
    Prashant

    I am sorry but I did add those in the classpath but still getting this error:
    This is what I have for user variable in classpath:
    .;C:\Oracle9i\jdbc\lib\ojdbc14.jar;C:\Oracle9i\jdbc\lib\nls_charset12.jar
    error is:
    java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at jdbc.InsertQueryEx.main(InsertQueryEx.java:14)
    Thanks

  • Exception in thread "main" java.lang.VerifyError: verification failed!!

    DB:11.1.0.7
    Oracle Apps:12.1.1
    OS:RHEL Linux 4 86x64
    Hi All,
    On executing the following command on node 2 of TEST instance, we received the following error but did not find any such error messages in node 1
    Notes: (1) Node 1 has java version:
    java -version
    java version "1.6.0_10"
    Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
    Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
    (2) Node 2 has java version:
    java -version
    java version "1.4.2"
    gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Error message in node2:
    On executing the following command on node 2 of TEST instance, we received the following error:
    java oracle.jrad.tools.xml.importer.XMLImporter /tmp/custdocs/oracle/apps/pos/home/webui/customizations/site/0/PosHpgOrders.xml ....
    /usr/bin/java: line 36: [: `)' expected, found -
    Exception in thread "main" java.lang.VerifyError: verification failed at PC 152 in oracle.jdbc.driver.OracleDriver:registerMBeans(()V): String, int, or float constant expected
    at JvBytecodeVerifier.verify_fail(byte, int) (/usr/lib64/libgcj.so.5.0.0)
    at JvBytecodeVerifier.verify_instructions_0() (/usr/lib64/libgcj.so.5.0.0)
    at JvVerifyMethod(_Jv_InterpMethod) (/usr/lib64/libgcj.so.5.0.0)
    at JvPrepareClass(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at JvWaitForState(java.lang.Class, int) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.Class.initializeClass() (/usr/lib64/libgcj.so.5.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.5.0.0)
    at oracle.adf.mds.tools.util.ConnectUtils.getDBConnection(java.lang.String) (Unknown Source)
    at oracle.jrad.tools.xml.importer.XMLImporter.importDocuments(java.lang.String[], java.sql.Connection) (Unknown Source)
    at oracle.jrad.tools.xml.importer.XMLImporter.main(java.lang.String[]) (Unknown Source)
    Could anyone please share such an issue faced before and provide resolution as to what's wrong in here in node 2?
    Thanks for your time!
    Regards,

    Hi,
    (2) Node 2 has java version:
    java -version
    java version "1.4.2"Do you run this command as applmgr user? If yes, did you source the application env file?
    Could anyone please share such an issue faced before and provide resolution as to what's wrong in here in node 2?Why the java version is different on the both nodes?
    Thanks,
    Hussein

  • Exception in thread "main" java.lang.NullPointerException

    hi
    I am new to Java, and taking an introductory course in java. I wrote the code given bellow and get following error "C:\java\assingment2>java test123
    Exception in thread "main" java.lang.NullPointerException
    at PartCatalog.Add(test123.java:56)
    at test123.main(test123.java:102)"
    Can any body help me please
    import java.util.*;
    class PartRecord
    public String PartName;
    public String PartNumber;
    public float Cost;
    public int Quantity;
    public static int counter ;
    public PartRecord()
    { PartName ="";
         PartNumber="";
    Cost = 0;
         Quantity = 0;
         counter = 0;
    public void Set(String name, final String num,
    float cost, int quantity)
         PartName = name;
    PartNumber= num;
    Cost = cost;
    Quantity = quantity;
    counter++;
    public float Get()
                   return Cost*Quantity;
    public static int Counter() {return counter;}
    class PartCatalog
    public PartCatalog()
    npart=0;
    public void Add(String name, String num,
    float cost, int quantity)
    if(npart>=1000) return;
    Parts[npart++].Set(name,num,cost,quantity);
    public float ShowInventory()
    int inventory = 0;
    for(int i=0; i<npart; i++)
    inventory+= Parts.Get();
    return inventory;
    public PartRecord[] Parts = new PartRecord[1000];
    public int npart;
    class ExtPartCatalog extends PartCatalog
    public void Sort()
    Arrays.sort(Parts);
    public void Print()
    for(int i=0; i<npart; i++)
    System.out.println ( Parts[i].PartName + "\t "
    + Parts[i].PartNumber + "\t "
    + Parts[i].Cost + "\t "
    + Parts[i].Quantity + "\n");
    class test123{
    public static void main(String args[])          
         ExtPartCatalog catalog = new ExtPartCatalog();
         catalog.Add("tire ", "1", 45, 200);
         catalog.Add("microwave", "2", 95, 10);
         catalog.Add("CD Player", "3", 215, 11);
         catalog.Add("Chair ", "4", 65, 10);
         catalog.Sort();
    catalog.Print();
    System.out.println("Inventory is " + catalog.ShowInventory());
    ExtPartCatalog catalog2 = new ExtPartCatalog();
    catalog2.Add("ttt ", "1", 45, 200);
    System.out.print("\n\nTotally there are " + PartRecord.Counter() );
    System.out.println(" Parts being set" );

    Thank you for your reply. I think i used
    public PartRecord[] Parts = new PartRecord[1000];
    so i have created the reference. I tries what you told me but it still did not work. I am putting the code again, but now in the formatted form so that you can read it more easily. I will appreciate your help. Thanks
    <code>
    import java.util.*;
    class PartRecord
    {      public String PartName;
    public String PartNumber;
    public float Cost;
    public int Quantity;
    public static int counter ;
         public PartRecord()
              PartName ="";
              PartNumber="";
              Cost = 0;
              Quantity = 0;
              //counter = 0;
         public void Set(String name, final String num,
    float cost, int quantity)
         PartName = name;
         PartNumber= num;
         Cost = cost;
         Quantity = quantity;
         counter++;
         public float Get()
         return Cost*Quantity;
         public static int Counter() {return counter;}
    class PartCatalog
    {      public PartRecord[] Parts = new PartRecord[1000];
         public int npart;
    public PartCatalog()
    npart=0;
         public void Add(String name, String num,
         float cost, int quantity)
         if(npart>=1000) return;
         Parts[npart++].Set(name,num,cost,quantity);
         public float ShowInventory()
              float inventory = 0;
              for(int i=0; i<npart; i++)
              inventory= Parts[npart].Get();
              return inventory;
    /*class ExtPartCatalog extends PartCatalog
         public void Sort()
         Arrays.sort(Parts);
         public void Print()
                   for(int i=0; i<npart; i++)
                   System.out.println ( Parts.PartName + "\t "
                                  + Parts[i].PartNumber + "\t "
                                  + Parts[i].Cost + "\t "
                             + Parts[i].Quantity + "\n");
    class azimi_a{
    public static void main(String args[])
    PartCatalog c = new PartCatalog() ;//= new PartCatalog[4];
    c.Add("tire ", "1", 45, 200);
    c.Add("microwave", "2", 95, 10);
    c.Add("CD Player", "3", 215, 11);
    c.Add("Chair ", "4", 65, 10);
    <code>

  • Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

    hi to all.
    iam getting this error: could any one give me the solution.
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at DinosaursDataLoader.getData(DinosaursDataLoader.java:49)
    at DinosaursPack.load(DinosaursPack.java:22)
    at DinosaursPack.<init>(DinosaursPack.java:18)
    at myproject.main(myproject.java:17)
    import java.util.*;
    import java.io.*;
    import javax.swing.ImageIcon;
    public class Driver {
        public static void main (String[] args) {
              // create a Scanner and grab the data . . .
                 File f=new File("C:\\Users\\hariprasad koineni\\Desktop\\r.txt");// my text file containes 12 dinosuor card info
              Scanner scanner = null;
              try {
                    scanner = new Scanner(f);
              } catch (FileNotFoundException fnf) {
                    System.out.println(fnf.getMessage());
                    System.exit(0);
            // scan file line-by-line
              scanner.useDelimiter("------------------------------------------------------------------");
              int y=0;
              while (scanner.hasNext()) {
                String line = scanner.next().trim();
                System.out.println(line);
                String bits[]= new String[19];
                String[] bit = line.split("\n");       // Regex available since Java 5
                for(int j=0;j<=(bit.length-1);j++){
                        String[] bis = bit[j].split(":");
                        System.out.println(bis[0]);
                        String t=bis[1].trim();
                        bits[j]=t;
                        System.out.println(bits[j]);
                        System.out.println(j);
                String t = bits[0];                        // title
                String imgFileName = bits[1];          // image file name
                float  h = Float.parseFloat(bits[2]);    // height
                String  w = bits[3];    // weight
                String  l = bits[4];    // length
                int  kr = Integer.parseInt(bits[5]);    // killer rating
                String  i = bits[6];     // intelligence
                int  a = Integer.parseInt(bits[7]);     // age
                String df = bits[8];                      // dino file
                // create the image
               y++;
             System.out.println(line);
             System.out.println(y);
    }

    h_koineni wrote:
    sorry
    iam getting the error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at Driver.main(Driver.java:38)So meaning this line cause the exception:
    String t=bis[1].trim(); // hard-coded int literal 1That happens because, in line 36,
    String[] bis = bit[j].split(":");What will happen if the delimiter ':' is not found? It will return an array with a size of 1, and at this time referencing index 1 is out of bound, remember that the upper bound of an array is its size-1. One workaround is to put a selection structure after line 36.
    if (bis != null && bis.length == 2) {
        String t=bis[1].trim();
        bits[j]=t;
    }Then, recompile your code and try again.

  • Exception in thread "main" java.lang.NumberFormatException:For input String

    this is a code about arrylist. but when I debug it.it metion:Exception in thread "main" java.lang.NumberFormatException:For input String at java.lang.NumberFormatException.forInputString(numberFomatExceptionio java:48)
    at java.lang.Integer.parseInt(integer.java:468)
    at java.lang.Integer.parseInt(integer.java:497)
    at Get.getInt(manerger.java:208)
    at LinkList.insertFirst(manager.java:94)
    at manager.main(manager.java;20)
    this is my code:
    import java.io.*;
    import java.lang.*;
    public class manager
         public static void main(String args[]) throws IOException
         LinkList list=new LinkList();
         System.out.println("input S can scan the grade\ninput D can delete one entry\ninput U can update the entry\ninput A can add one entry\ninput E can end");
         int cr=System.in.read();
    switch(cr)
         case 'A':
         list.insertFirst();break;//this is 20 row
         case 'S':
         System.out.println("input the s");break;
         case 'D':
         System.out.println("input the d");break;
         case 'U':
         System.out.println("input the u");break;
    class Link
    public int number;
    public String name=new String();
    public int chs;
    public int eng;
    public int math;
    public Link next;
    public Link(int number,String name, int chs,int eng,int math)
    this.number=number;
    this.name=name;
    this.chs=chs;
    this.eng=eng;
    this.math=math;
    public Link()
         this(0,"",0,0,0);
    public void displayLink()
    System.out.println(number + " "+name+ " "+chs+ " "+eng+ " "+math+ " ");
    class LinkList
    public Link first;
    public LinkList()
    first = null;
    public boolean isEmpty()
    return first==null;
    public void displayList()
         System.out.println("");
         Link current=first;
         while(current!=null)
              current.displayLink();
              current=current.next;
         System.out.println("");
    public Link insertFirst() throws IOException
         Get getdata=new Get();
         int number=getdata.getInt();//this is 94 row
         String name=getdata.getString();
         int chs=getdata.getInt();
         int eng=getdata.getInt();
         int math=getdata.getInt();
         Link newLink = new Link(number,name,chs,eng,math);
         first=newLink;
         return first;
    public Link find(int key)
         Link current=first;
         while(current.number!=key)
              if(current.next==null)
              return null;
              else
              current=current.next;
         return current;
    public Link update(int key) throws IOException
         Link current=first;
         while(current.number!=key)
         if(current.next==null)
         return null;
         else
              System.out.println("Input the first letter of the subject:");
         int c=System.in.read();
         Get get=new Get();
              switch(c)
                   case 'c':
                   current.chs=get.getInt();break;
                   case 'e':
                   current.eng=get.getInt();break;
                   case 'm':
                   current.math=get.getInt();break;
         return current;
    public float average(char key)
         Link current=first;
         float total=0;
         float average=0;
         float counter=0;
         if(current==null)
         return 0;
         while(current!=null)
              switch(key)
                   case 'c':
                   total=current.chs+current.next.chs;break;
                   case 'e':
                   total=current.eng+current.next.eng;break;
                   case 'm':
                   total=current.math+current.next.math;break;
              current=current.next.next;
              counter++;
         average=total/counter;
         return average;
    public Link delete(int key)
         Link current=first;
         Link previous=first;
         while(current.number!=key)
              if(current.next==null)
              return null;
              else
                   previous=current;
                   current=current.next;
              if(current==first)
              first=first.next;
              else
              previous.next=current.next;
              return current;
    class Get
    public static String getString() throws IOException
    System.out.println("Input your name:");
    InputStreamReader str = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(str);
    String s = br.readLine();
    return s;
    public static int getInt() throws IOException
    System.out.println("Input your data:");
    String st = getString();
    return Integer.parseInt(st);//this is 208 row
    }

    It may be that the code in getString() returns a
    String that ends with a newline. If that is the
    problem, you can use
    return (Integer.parseInt(st)).trim();1. getString will never return a String ending in newline. BufferedReader.readLine strips off the newline.
    2. Even if you had a newline, String.trim doesn't trim newlines.
    3. You would need to trim the String, not the int:
    return (Integer.parseInt(st.trim()));As JimDinosaur said, you are passing bad data (the value of "st").
    In getInt, add this before trying to parse "st":
    System.out.println("###"+st+"###");What does it print?

Maybe you are looking for

  • Mimi not recognized by computer or itunes

    a few months back i downloaded the newest updates for itunes and my mini. i've trouble ever since getting my computer or itunes to recognize my mini. tonight it won't do it all. i've shut itunes down, tried different USB ports.... it tried to find it

  • How to find out the calling point of a Badi

    Hi Experts, Say one Badi is getting called in a particular screen of a transaction. Can anyone please guide me how to find out the calling point for that Badi. I checked for transaction CC31 screen 2000, method IF_EX_ECM_EXIT~OMR_CHECK_01 is getting

  • Audio and video out of sync when using quicktime conversion

    hello, i am editing a hdv project and want to export to quicktime. the client needs it in a specific size (700x394). they do not want the video in the file compressed, just the size of image. they are compressing the video through flash for the web.

  • [SCCM 2012 R2] Windows Update Agent do not scan correctly thus SCCM has bad reports

    Hi All, My colleagues reported that after manual download and installation of update Office 2010 SP2 ... SCCM still do not report as Installed: https://support.microsoft.com/en-us/kb/2687455 KB2687455 update on SCCM is reported as: Update ID: 9c5e43a

  • Cannot connect to ANY toll free numbers in the USA...

    I am unable to use Skype to call ANY toll free numbers any where on the planet EVER! 95% of them are in the USA and 5% are in Canada. I have tried uninstalling/reinstalling etc. but it is useless. I can only make calls with the company's main numbers