Search Results

Search found 62 results on 3 pages for 'numberformatexception'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Eclipse - Handling Java Exceptions like in NetBeans

    - by Xorty
    I recently moved from NetBeans to Eclipse and I very much miss one great feature - whenever I use method which throws some kind of exception, NetBeans alerted me and I needed to add try-catch and NetBeans automatically generated exception type for me. Is there something similiar for Eclipse? f.e. : Integer.parseInt(new String("foo")); NetBeans alerts I need to catch NumberFormatException. Eclipse doesn't alert me at all I am using Eclipse Java EE IDE for Web Developers, 3.5 - Galileo

    Read the article

  • How to differentiate between Programmer and JVM Exceptions

    - by Haxed
    As the title suggests, how can I tell a JVM thrown exception from a Programmatically(does this mean, thrown by a programmer or the program) thrown exception ? JVM Exceptions 1) ArrayIndexOutOfBoundsException 2) ClassCastException 3) NullPointerException Programmatically thrown 1) NumberFormatException 2) AssertionError Many Thanks

    Read the article

  • How to deferentiate between Programmer and JVM Exceptions

    - by Haxed
    As the title suggests, how can I tell a JVM thrown exception from a Programmatically(does this mean, thrown by a programmer or the program) thrown exception ? JVM Exceptions 1) ArrayIndexOutOfBoundsException 2) ClassCastException 3) NullPointerException Programmatically thrown 1) NumberFormatException 2) AssertionError Many Thanks

    Read the article

  • Problem with large number of markers on the map...

    - by bobetko
    I am working on an Android app that already exists on iPhone. In the app, there is a Map activity that has (I counted) around 800 markers in four groups marked by drawable in four different colors. Each group can be turned on or off. Information about markers I have inside List. I create a mapOverlay for each group, then I attach that overlay to the map. I strongly believe that coding part I did properly. But I will attach my code anyway... The thing is, my Nexus One can't handle map with all those markers. It takes around 15 seconds just to draw 500 markers. Then when all drawn, map is not quite smooth. It is sort of hard to zoom and navigate around. It can be done, but experience is bad and I would like to see if something can be done there. iPhone seems doesn't have problems showing all these markers. It takes roughly about 1-2 seconds to show all of them and zooming and panning is not that bad. Slow down is noticeable but still acceptable. I personally think it is no good to draw all those markers, but app is designed by somebody else and I am not supposed to make any drastic changes. I am not sure what to do here. It seems I will have to come up with different functionality, maybe use GPS location, if known, and draw only markers within some radius, or, if location not known, use center of the screen(map) and draw markers around that. I will have to have reasonable explanation for my bosses in case I make these changes. I appreciate if anybody has any idas. And the code: ... for (int m = 0; m < ArrList.size(); m++) { tName = ArrList.get(m).get("name").toString(); tId = ArrList.get(m).get("id").toString(); tLat = ArrList.get(m).get("lat").toString();; tLng = ArrList.get(m).get("lng").toString();; try { lat = Double.parseDouble(tLat); lng = Double.parseDouble(tLng); p1 = new GeoPoint( (int) (lat * 1E6), (int) (lng * 1E6)); OverlayItem overlayitem = new OverlayItem(p1, tName, tId); itemizedoverlay.addOverlay(overlayitem); } catch (NumberFormatException e) { Log.d(TAG, "NumberFormatException" + e); } } mapOverlays.add(itemizedoverlay); mapView.postInvalidate(); ................................ public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem> { private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); private Context mContext; public HelloItemizedOverlay(Drawable defaultMarker, Context context) { super(boundCenterBottom(defaultMarker)); mContext = context; } public void addOverlay(OverlayItem overlay) { mOverlays.add(overlay); populate(); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } @Override protected boolean onTap(int index) { final OverlayItem item = mOverlays.get(index); ... EACH MARKER WILL HAVE ONCLICK EVENT THAT WILL PRODUCE CLICABLE ... BALOON WITH MARKER'S NAME. return true; } }

    Read the article

  • Bad value for type timestamp on production server

    - by Juan Javaloyes
    I'm working with: seam 2.2.2 + hibernate + richfaces + jboss 5.1 + postgres I have an module which needs to load some data from the database. Easy. The problem is, on development it works fine, 100%, but when I deploy on my production server and try to get the data, an error rise: could not read column value from result set: fechahor9_504_; Bad value for type timestamp : [C@122e5cf SQL Error: 0, SQLState: 22007 Bad value for type timestamp : [C@122e5cf javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute query [more errors] Caused by: org.postgresql.util.PSQLException: Bad value for type timestamp : [C@122e5cf at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:232) [more errors] Caused by: java.lang.NumberFormatException: Trailing junk on timestamp: '' at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:226) I can't understand why it works on my machine (development) and why not on production. Any clues? Anyone gone through the same problem? Is exactly the same compilation

    Read the article

  • Spring MVC defaultValue for Double

    - by mlathe
    Hi All, I'm trying to build a controller like this: @RequestMapping(method = {RequestMethod.GET}, value = "/users/detail/activities.do") public View foo(@RequestParam(value = "userCash", defaultValue="0.0") Double userCash) { System.out.println("foo userCash=" + userCash); } This works fine: http://localhost/app/users/detail/activities.do?userCash=123& but in this one userCash==null despite the default value http://localhost/app/users/detail/activities.do?userCash=& From some digging it seems like the first one works b/c of a Editor binding like this: binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, false)); The trouble is that the second param (ie false) defines whether blank values are allowed. If i set that to true, than the system considers the blank input as valid so i get a null Double class. If i set it to false then the system chokes on the blank input string with: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'double'; nested exception is java.lang.NumberFormatException: empty String Does anyone know how to get the defaultValue to work for Doubles? Thanks --Matthias

    Read the article

  • Does form with enctype="multipart/form-data" cause problems accessing a hidden field

    - by Ankur
    I have created a hidden form element <form name="UploadImage" enctype="multipart/form-data" method="post" action="UploadImage"> <label> </label> <input name="imgUploadObjId" id="imgUploadObjId" value="52" type="hidden"> //rest of the form here </form> And I am trying to get the value with this line in a servlet (as I have done before): int objId = Integer.parseInt(request.getParameter("imgUploadObjId")); But I get this (line 33 is the line above): java.lang.NumberFormatException: null java.lang.Integer.parseInt(Unknown Source) java.lang.Integer.parseInt(Unknown Source) web.objects.UploadImage.doPost(UploadImage.java:33) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) Is there something different about a form with enctype="multipart/form-data"? Or can you see some other error.

    Read the article

  • Using only alphanumeric characters(a-z) inside toCharArray

    - by Aaron
    Below you will find me using toCharArray in order to send a string to array. I then MOVE the value of the letter using a for statement... for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } However, when I use shiftCode to move the value such as... a shifted by -1; I get a symbol @. Is there a way to send the string to shiftCode or tell shiftCode to ONLY use letters? I need it to see my text, like "aaron", and when I use the for statement iterate through a-z only and ignore all symbols and numbers. I THINK it is as simple as... letter=codeWord.toCharArray(a,z); But trying different forms of that and googling it didn't give me any results. Perhaps it has to do with regex or something? Below you will find a complete copy of my program; it works exactly how I want it to do; but it iterates through letters and symbols. I also tried finding instructions online for toCharArray but if there exists any arguments I can't locate them. My program... import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * Aaron L. Jones * CS219 * AaronJonesProg3 * * This program is designed to - * Work as a Ceasar Cipher */ /** * * Aaron Jones */ public class AaronJonesProg3 { static String codeWord; static int shiftCode; static int i; static char[] letter; /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // Instantiating that Buffer Class // We are going to use this to read data from the user; in buffer // For performance related reasons BufferedReader reader; // Building the reader variable here // Just a basic input buffer (Holds things for us) reader = new BufferedReader(new InputStreamReader(System.in)); // Java speaks to us here / We get it to query our user System.out.print("Please enter text to encrypt: "); // Try to get their input here try { // Get their codeword using the reader codeWord = reader.readLine(); // Make that input upper case codeWord = codeWord.toUpperCase(); // Cut the white space out codeWord = codeWord.replaceAll("\\s",""); // Make it all a character array letter = codeWord.toCharArray(); } // If they messed up the input we let them know here and end the prog. catch(Throwable t) { System.out.println(t.toString()); System.out.println("You broke it. But you impressed me because" + "I don't know how you did it!"); } // Java Speaks / Lets get their desired shift value System.out.print("Please enter the shift value: "); // Try for their input try { // We get their number here shiftCode = Integer.parseInt(reader.readLine()); } // Again; if the user broke it. We let them know. catch(java.lang.NumberFormatException ioe) { System.out.println(ioe.toString()); System.out.println("How did you break this? Use a number next time!"); } for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } System.out.println(); /**************************************************************** **************************************************************** ***************************************************************/ // Java speaks to us here / We get it to query our user System.out.print("Please enter text to decrypt: "); // Try to get their input here try { // Get their codeword using the reader codeWord = reader.readLine(); // Make that input upper case codeWord = codeWord.toUpperCase(); // Cut the white space out codeWord = codeWord.replaceAll("\\s",""); // Make it all a character array letter = codeWord.toCharArray(); } // If they messed up the input we let them know here and end the prog. catch(Throwable t) { System.out.println(t.toString()); System.out.println("You broke it. But you impressed me because" + "I don't know how you did it!"); } // Java Speaks / Lets get their desired shift value System.out.print("Please enter the shift value: "); // Try for their input try { // We get their number here shiftCode = Integer.parseInt(reader.readLine()); } // Again; if the user broke it. We let them know. catch(java.lang.NumberFormatException ioe) { System.out.println(ioe.toString()); System.out.println("How did you break this? Use a number next time!"); } for(i = 0; i < letter.length; i++){ letter[i] += (shiftCode); System.out.print(letter[i]); } System.out.println(); } }

    Read the article

  • Birt Global Integer

    - by matschie
    Hi there I have a Birt Report which read some stuff from a database. After that i want to increment a global Integer for every Detailrow that is loaded. So far i have initialized a global Integer with the following lines: importPackage(Packages.java.lang); reportContext.setPersistentGlobalVariable("minTotalPlus", new Integer(0)); After that i added the following line into a field in my detail row: reportContext.setGlobalVariable("minTotalPlus", new Integer reportContext.getGlobalVariable("minTotalPlus")) + 1); When i preview the report i get an "java.lang.NumberFormatException: null" which means that the global variable is null. Why is that so? How could I fix that?

    Read the article

  • How can i take only integer input from keyboard and if input is invalid how do i ask user agaian

    - by fari
    This is what i have written so far but when exception is raised it does not again ask teh user for input. do{ System.out.println("Enter the number of stones to play with: "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String temp=br.readLine(); }while (key<0 && key>9); if(key<0 || key>10) throw new InvalidStartingStonesException(key); player1=new KeyBoardPlayer(); player2 = new KeyBoardPlayer(); this.player1=player1; this.player2=player2; state=new KalaGameState(key); } catch(NumberFormatException nFE) { System.out.println("Not an Integer");} catch(IOException e) { System.out.println(e); }

    Read the article

  • DecimalFormat and Double.valueOf()

    - by folone
    Hello. I'm trying to get rid of unnecessary symbols after decimal seperator of my double value. I'm doing it this way: DecimalFormat format = new DecimalFormat("#.#####"); value = Double.valueOf(format.format(41251.50000000012343)); But when I run this code, it throws: java.lang.NumberFormatException: For input string: "41251,5" at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224) at java.lang.Double.valueOf(Double.java:447) at ... As I see, Double.valueOf() works great with strings like "11.1", but it chokes on strings like "11,1". How do I work around this? Is there a more elegant way then something like Double.valueOf(format.format(41251.50000000012343).replaceAll(",", ".")); Is there a way to override the default decimal separator value of DecimalFormat class?

    Read the article

  • parsing primitive types using java.util.Scanner

    - by Rich Fluckiger
    I'm new to java so forgive the noob question. I have created a swing application that basically has three input strings in JTextFields: loanAmount, interestRate and loanYears and a single submit button with the EventAction. I'm trying to use the java.util.Scanner to parse the input to primitive types that I can use in calculations. I'm getting an error in NetBeans indicating that my variables are not recognized? should I not be calling System.in? private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) { Scanner keyInput = new Scanner(System.in); while (true) try{ double amount = keyInput.nextDouble(loanAmount.getText()); double interest = keyInput.nextDouble(interestRate.getText()); int years = keyInput.nextInt(loanYears.getText()); } catch (NumberFormatException nfe){ } }

    Read the article

  • Android string formatiing from xml

    - by mann
    I am parsing xml from server. One of its node contains data like <distance>16.3432434324354324km</distance> I am putting it into hashmap like for (int i = 0; i < nl.getLength(); i++) { map.put(KEY_DISTANCE, parser.getValue(e, KEY_DISTANCE)); // adding HashList to ArrayList menuItems.add(map); } Everything is nice. But i want it two decimal places for example i want its value should be 16.34km rather then 16.343234324342342km I tried with DecimalFormat twoDForm=new DecimalFormat("##.00"); try{ Double StartVTwo=Double.valueOf(KEY_DISTANCE); Double resultDouble1 = Double.valueOf(twoDForm.format(StartVTwo)); Log.e("check", String.valueOf(resultDouble1)); }catch (NumberFormatException e){ Log.e("error"," This is error "); } But it shows exception and prints this message. Any help would be appreciated!!

    Read the article

  • TXT file not showing properly in Android

    - by narkelion
    I developed an app for Android, that loads some data from some .txt files I created. Until now, everything went fine. Today I updated these texts to add some stuff, and now Android comes out with this error in the LogCat: 06-06 23:16:03.925: W/System.err(7999): java.lang.NumberFormatException: Invalid int: "?72" It never happened before. If I read the txt from my computer, I can see that all seems in the right place. But if I read it from the Android editor, I see strange symbols (close to that 72). I don't know how to remove them, because I cannot see them on the pc!

    Read the article

  • Exception for java Swing application?

    - by Rich Fluckiger
    For some reason this is locking up the java application. Did I handle the exception correctly? private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) { double amount, interest,rateCalc, a, b, c, payment; int years, months; while (true){ try{ amount = Double.valueOf(loanAmount.getText()); interest = Double.valueOf(interestRate.getText()); years = Integer.valueOf(loanYears.getText()); rateCalc = (interest/12); months = (years*12); a = Math.pow((1+rateCalc),months); b = (a*rateCalc); c = (a-1); payment = (amount *(b/c)); monthlyPayment.setText("Mortgage Payment $ = " + payment); } catch (NumberFormatException nfe){ javax.swing.JOptionPane.showMessageDialog(null, "Please enter numbers and not letters"); return; } } } monthlyPayment returns to the java app.

    Read the article

  • How do I setup Eclipse to stop on the line an exception occured?

    - by Chris Persichetti
    Hi, How can I setup Eclipse to stop at the point an exception occurred. I have an Eclipse breakpoint setup to break on an exception. In the code example below, the problem I'm having is Eclipse tries to open the Integer source code. Is there any way to just have debugger break at the point shown in my code example? If I move down the stack trace, I will get to this line, it'd be nice if there's a way to do this without the "Source not found" window coming up. This can be done in Visual Studio, so it's driving me crazy not being able to find a way to do this in Eclipse. package com.test; public class QuickTest { public static void main(String[] args) { try { test(); } catch(NumberFormatException e) { System.out.println(e.getMessage()); } } private static void test() { String str = "notAnumber"; Integer.parseInt(str);//<----I want debugger to stop here } }

    Read the article

  • parseInt and viewflipper layout problems

    - by user1234167
    I have a problem with parseInt it throws the error: unable to parse 'null' as integer. My view flipper is also not working. Hopefully this is an easy enough question. Here is my activity: import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ViewFlipper; import xml.parser.dataset; public class XmlParserActivity extends Activity implements OnClickListener { private final String MY_DEBUG_TAG = "WeatherForcaster"; // private dataset myDataSet; private LinearLayout layout; private int temp= 0; /** Called when the activity is first created. */ //the ViewSwitcher private Button btn; private ViewFlipper flip; // private TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); layout=(LinearLayout)findViewById(R.id.linearlayout1); btn=(Button)findViewById(R.id.btn); btn.setOnClickListener(this); flip=(ViewFlipper)findViewById(R.id.flip); //when a view is displayed flip.setInAnimation(this,android.R.anim.fade_in); //when a view disappears flip.setOutAnimation(this, android.R.anim.fade_out); // String postcode = null; // public String getPostcode { // return postcode; // } //URL newUrl = c; // myweather.setText(c.toString()); /* Create a new TextView to display the parsingresult later. */ TextView tv = new TextView(this); // run(0); //WeatherApplicationActivity postcode = new WeatherApplicationActivity(); try { /* Create a URL we want to load some xml-data from. */ URL url = new URL("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query=G41"); //String url = new String("http://new.myweather2.com/developer/forecast.ashx?uac=gcV3ynNdoV&output=xml&query="+WeatherApplicationActivity.postcode ); //URL url = new URL(url); //url.toString( ); //myString(url.toString() + WeatherApplicationActivity.getString(postcode)); // url + WeatherApplicationActivity.getString(postcode); /* Get a SAXParser from the SAXPArserFactory. */ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); /* Get the XMLReader of the SAXParser we created. */ XMLReader xr = sp.getXMLReader(); /* Create a new ContentHandler and apply it to the XML-Reader*/ handler myHandler = new handler(); xr.setContentHandler(myHandler); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(url.openStream())); /* Parsing has finished. */ /* Our ExampleHandler now provides the parsed data to us. */ dataset parsedDataSet = myHandler.getParsedData(); /* Set the result to be displayed in our GUI. */ tv.setText(parsedDataSet.toString()); } catch (Exception e) { /* Display any Error to the GUI. */ tv.setText("Error: " + e.getMessage()); Log.e(MY_DEBUG_TAG, "WeatherQueryError", e); } temp = Integer.parseInt(xml.parser.dataset.getTemp()); if(temp <0){ //layout.setBackgroundColor(Color.BLUE); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.BLUE); } else if(temp > 0 && temp < 9) { //layout.setBackgroundColor(Color.GREEN); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.GREEN); } else { //layout.setBackgroundColor(Color.YELLOW); //layout.setBackgroundColor(getResources().getColor(R.color.silver)); findViewById(R.id.flip).setBackgroundColor(Color.YELLOW); } /* Display the TextView. */ this.setContentView(tv); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub onClick(View arg0) { // TODO Auto-generated method stub flip.showNext(); //specify flipping interval //flip.setFlipInterval(1000); //flip.startFlipping(); } } this is my dataset: package xml.parser; public class dataset { static String temp = null; // private int extractedInt = 0; public static String getTemp() { return temp; } public void setTemp(String temp) { this.temp = temp; } this is my handler: public void characters(char ch[], int start, int length) { if(this.in_temp){ String setTemp = new String(ch, start, length); // myParsedDataSet.setTempUnit(new String(ch, start, length)); // myParsedDataSet.setTemp; } the dataset and handler i only pasted the code that involves the temp as i no they r working when i take out the if statement. However even then my viewflipper wont work. This is my main xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/linearlayout1" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip Example" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="25dip" android:text="Flip" android:id="@+id/btn" android:onClick="ClickHandler" /> <ViewFlipper android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/flip"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:text="Item1a" /> </LinearLayout> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="25dip" android:id="@+id/tv2" /> </ViewFlipper> </LinearLayout> this is my logcat: 04-01 18:02:24.744: E/AndroidRuntime(7331): FATAL EXCEPTION: main 04-01 18:02:24.744: E/AndroidRuntime(7331): java.lang.RuntimeException: Unable to start activity ComponentInfo{xml.parser/xml.parser.XmlParserActivity}: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.os.Looper.loop(Looper.java:150) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.main(ActivityThread.java:4293) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.reflect.Method.invoke(Method.java:507) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849) 04-01 18:02:24.744: E/AndroidRuntime(7331): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) 04-01 18:02:24.744: E/AndroidRuntime(7331): at dalvik.system.NativeStart.main(Native Method) 04-01 18:02:24.744: E/AndroidRuntime(7331): Caused by: java.lang.NumberFormatException: unable to parse 'null' as integer 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:356) 04-01 18:02:24.744: E/AndroidRuntime(7331): at java.lang.Integer.parseInt(Integer.java:332) 04-01 18:02:24.744: E/AndroidRuntime(7331): at xml.parser.XmlParserActivity.onCreate(XmlParserActivity.java:118) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072) 04-01 18:02:24.744: E/AndroidRuntime(7331): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794) I hope I have given enough information about my problems. I will be extremely grateful if anyone can help me out.

    Read the article

  • Problem upgrading eclipse rcp app from 3.3 to 3.5 on Mac OS

    - by Alb
    I previously had an eclipse rcp app based on eclipse 3.3 pugins deployed on both windows and mac OS X 10.4. i'm now trying to port the app to java 1.6 and eclipse 3.5 (Build id: 20100218-1602) plugins on Mac OS X 10.5.8 (Leopard). I can launch the product from eclipse 3.5 on windows but not on Mac OS X. I have the 64bit cocoa eclipse IDE and java 6. In the launch configuration I set runtime JRE to JVM 1.6.0 and added required plugins. The plugins validate and everything else looks similar to windows configuration where it works, but when I launch i only get the following two lines in the console: 2010-03-16 13:29:32.742 java[758:10b] [Java CocoaComponent compatibility mode]: Enabled 2010-03-16 13:29:32.744 java[758:10b] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000 and then the program appears to just hang indefinitely. There is nothing written to the .log file so I'm not sure what error there is. EDIT: Here's what Yourkit profiling says before all cpu activity stops. +----------------------------------------------------------------------------+----------------+-----------------+ | Name | Time (ms) | Own Time (ms) | +----------------------------------------------------------------------------+----------------+-----------------+ | +---<All threads> | 2,799 100 % | | | | | | | | +---org.eclipse.equinox.launcher.Main.main(String[]) | 1,924 69% | 0 | | | | | | | +---org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run() | 632 23 % | 0 | | | | | | | +---java.lang.Thread.run() | 135 5 % | 0 | | | | | | | +---java.lang.ClassLoader.loadClassInternal(String) | 106 4 % | 0 | +----------------------------------------------------------------------------+----------------+-----------------+ , and this in the exceptions tab: Exception staticstics +----------------------------------------+--------------+ | Name | Count | +----------------------------------------+--------------+ | +---java.lang.ClassNotFoundException | 102 11 % | | | | | | +---java.net.MalformedURLException | 4 0 % | | | | | | +---java.lang.NoSuchMethodException | 3 0 % | | | | | | +---java.lang.NumberFormatException | 2 0 % | | | | | | +---java.io.FileNotFoundException | 1 0 % | | | | | | +---java.lang.UnsatisfiedLinkError | 1 0 % | +----------------------------------------+--------------+ and here's more details on the ClassNotFoundExceptions mentioned above: java.lang.ClassNotFoundException Start Level Event Dispatcher native ID: 0x8B0B group: 'main' 78 Thread-4 native ID: 0x10B group: 'main' 22 Framework Event Dispatcher native ID: 0xD207 group: 'main' 2 Anyone know why I don't see a trace for this in Eclipse or in any log files? any ideas where I should look? [Updated on: Tue, 16 March 2010 09:37]

    Read the article

  • I am getting a Radix out of range exception on performing decryption

    - by user3672391
    I am generating a keypair and converting one of the same into string which later is inserted into the database using the following code: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); KeyPair generatedKeyPair = keyGen.genKeyPair(); PublicKey pubkey = generatedKeyPair.getPublic(); PrivateKey prvkey = generatedKeyPair.getPrivate(); System.out.println("My Public Key>>>>>>>>>>>"+pubkey); System.out.println("My Private Key>>>>>>>>>>>"+prvkey); String keyAsString = new BigInteger(prvkey.getEncoded()).toString(64); I then retrieve the string from the database and convert it back to the original key using the following code (where rst is my ResultSet): String keyAsString = rst.getString("privateKey").toString(); byte[] bytes = new BigInteger(keyAsString, 64).toByteArray(); //byte k[] = "HignDlPs".getBytes(); PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(bytes); KeyFactory rsaKeyFac = KeyFactory.getInstance("RSA"); PrivateKey privKey = rsaKeyFac.generatePrivate(encodedKeySpec); On using the privKey for RSA decryption, I get the following exception java.lang.NumberFormatException: Radix out of range at java.math.BigInteger.<init>(BigInteger.java:294) at com.util.SimpleFTPClient.downloadFile(SimpleFTPClient.java:176) at com.Action.FileDownload.processRequest(FileDownload.java:64) at com.Action.FileDownload.doGet(FileDownload.java:94) Please guide.

    Read the article

  • Basic jUnit Questions

    - by Epitaph
    I was testing a String multiplier class with a multiply() method that takes 2 numbers as inputs (as String) and returns the result number (as String) `public String multiply(String num1, String num2); I have done the implementation and created a test class with the following test cases involving the input String parameter as 1) valid numbers 2) characters 3) special symbol 4) empty string 5) Null value 6) 0 7) Negative number 8) float 9) Boundary values 10) Numbers that are valid but their product is out of range 11) numbers will + sign (+23) 1) I'd like to know if "each and every" assertEquals() should be in it's own test method? Or, can I group similar test cases like testInvalidArguments() to contains all asserts involving invalid characters since ALL of them throw the same NumberFormatException ? 2) If testing an input value like character ("a"), do I need to include test cases for ALL scenarios? "a" as the first argument "a" as the second argument "a" and "b" as the 2 arguments 3) As per my understanding, the benefit of these unit tests is to find out the cases where the input from a user might fail and result in an exception. And, then we can give the user with a meaningful message (asking them to provide valid input) instead of an exception. Is that the correct? And, is it the only benefit? 4) Are the 11 test cases mentioned above sufficient? Did I miss something? Did I overdo? When is enough? 5) Following from the above point, have I successfully tested the multiply() method?

    Read the article

  • Cannot find symbol - variable

    - by Ben Garside
    I'm new to Java, and I'm trying to get user input, store each line of input as a variable and then return each value so that it can be passed on somewhere else. When I try and compile it is telling me that it can't find the variable magnitude. I'm assuming it won't find the others either. I'm guessing that this is because I've declare the variables inside of the "try" but don't know how to get it so that the return statement accepts them. Code is as follows: public Earthquake userAddEarthquake() { Scanner scanner = new Scanner(System.in); try{ // convert the string read from the scanner into Integer type System.out.println("Please Enter An Earthquake Magnitude: "); Double magnitude = Double.parseDouble(scanner.nextLine()); System.out.println("Please Enter The Earthquakes Latitude Position: "); scanner = new Scanner(System.in); Double positionLatitude = Double.parseDouble(scanner.nextLine()); System.out.print("Please Enter The Earthquakes Longitude Position: "); scanner = new Scanner(System.in); Double positionLongitude = Double.parseDouble(scanner.nextLine()); System.out.print("Please Enter The Year That The Earthquake Occured: "); scanner = new Scanner(System.in); int year = Integer.parseInt(scanner.nextLine()); System.out.println("Magnitude = " + magnitude); } catch(NumberFormatException ne){ System.out.println("Invalid Input"); } finally{ scanner.close(); } return new Earthquake(magnitude, positionLatitude, positionLongitude, year); }

    Read the article

  • JAVA Casting error

    - by user1612725
    Im creating a program that uses Dijksrtras algorithm, im using nodes that represent cities on an imported map, and you can create edges between two cities on the map. My problem is every edge has a "weight" where it will represent distance in minutes and i have a function where i want to see the distance between the two edges. But i keep getting the error "Cannot cast from Stad to Edge" at the line Edge<Stad> selectedEdge = (Edge) fvf.visaFörbLista.getSelectedValue(); where "Stad" represents the city and "Edge" an edge. FormVisaförbindelse fvf = new FormVisaförbindelse(); for(;;){ try{ int svar = showConfirmDialog(null, fvf, "Ändra Förbindelser", JOptionPane.OK_CANCEL_OPTION); if (svar != YES_OPTION) return; if (fvf.visaFörbLista.isSelectionEmpty() == true){ showMessageDialog(mainMethod.this, "En Förbindelse måste valjas.","Fel!", ERROR_MESSAGE); return; } Edge<Stad> selectedEdge = (Edge) fvf.visaFörbLista.getSelectedValue(); FormÄndraförbindelse faf = new FormÄndraförbindelse(); faf.setförbNamn(selectedEdge.getNamn()); for(;;){ try{ int svar2 = showConfirmDialog(mainMethod.this, faf, "Ändra Förbindelse", OK_CANCEL_OPTION); if (svar2 != YES_OPTION) return; selectedEdge.setVikt(faf.getförbTid()); List<Edge<Stad>> edges = lg.getEdgesBetween(sB, sA); for (Edge<Stad> edge : edges){ if (edge.getNamn()==selectedEdge.getNamn()){ edge.setVikt(faf.getförbTid()); } } return; } catch(NumberFormatException e){ showMessageDialog(mainMethod.this, "Ogiltig inmatning.","Fel!", ERROR_MESSAGE); }

    Read the article

  • Issue reading in a cell from Excel with Apache POI

    - by Nick
    I am trying to use Apache POI to read in old (pre-2007 and XLS) Excel files. My program goes to the end of the rows and iterates back up until it finds something that's not either null or empty. Then it iterates back up a few times and grabs those cells. This program works just fine reading in XLSX and XLS files made in Office 2010. I get the following error message: Exception in thread "main" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) at java.lang.Double.parseDouble(Unknown Source) at the line: num = Double.parseDouble(str); from the code: str = cell.toString(); if (str != "" || str != null) { System.out.println("Cell is a string"); num = Double.parseDouble(str); } else { System.out.println("Cell is numeric."); num = cell.getNumericCellValue(); } where the cell is the last cell in the document that's not empty or null. When I try to print the first cell that's not empty or null, it prints nothing, so I think I'm not accessing it correctly.

    Read the article

  • Validating parameters according to a fixed reference

    - by James P.
    The following method is for setting the transfer type of an FTP connection. Basically, I'd like to validate the character input (see comments). Is this going overboard? Is there a more elegant approach? How do you approach parameter validation in general? Any comments are welcome. public void setTransferType(Character typeCharacter, Character optionalSecondCharacter) throws NumberFormatException, IOException { // http://www.nsftools.com/tips/RawFTP.htm#TYPE // Syntax: TYPE type-character [second-type-character] // // Sets the type of file to be transferred. type-character can be any // of: // // * A - ASCII text // * E - EBCDIC text // * I - image (binary data) // * L - local format // // For A and E, the second-type-character specifies how the text should // be interpreted. It can be: // // * N - Non-print (not destined for printing). This is the default if // second-type-character is omitted. // * T - Telnet format control (<CR>, <FF>, etc.) // * C - ASA Carriage Control // // For L, the second-type-character specifies the number of bits per // byte on the local system, and may not be omitted. final Set<Character> acceptedTypeCharacters = new HashSet<Character>(Arrays.asList( new Character[] {'A','E','I','L'} )); final Set<Character> acceptedOptionalSecondCharacters = new HashSet<Character>(Arrays.asList( new Character[] {'N','T','C'} )); if( acceptedTypeCharacters.contains(typeCharacter) ) { if( new Character('A').equals( typeCharacter ) || new Character('E').equals( typeCharacter ) ){ if( acceptedOptionalSecondCharacters.contains(optionalSecondCharacter) ) { executeCommand("TYPE " + typeCharacter + " " + optionalSecondCharacter ); } } else { executeCommand("TYPE " + typeCharacter ); } } }

    Read the article

  • java number exceeds long.max_value - how to detect?

    - by jurchiks
    I'm having problems detecting if a sum/multiplication of two numbers exceeds the maximum value of a long integer. Example code: long a = 2 * Long.MAX_VALUE; System.out.println("long.max * smth > long.max... or is it? a=" + a); This gives me -2, while I would expect it to throw a NumberFormatException... Is there a simple way of making this work? Because I have some code that does multiplications in nested IF blocks or additions in a loop and I would hate to add more IFs to each IF or inside the loop. Edit: oh well, it seems that this answer from another question is the most appropriate for what I need: http://stackoverflow.com/a/9057367/540394 I don't want to do boxing/unboxing as it adds unnecassary overhead, and this way is very short, which is a huge plus to me. I'll just write two short functions to do these checks and return the min or max long. Edit2: here's the function for limiting a long to its min/max value according to the answer I linked to above: /** * @param a : one of the two numbers added/multiplied * @param b : the other of the two numbers * @param c : the result of the addition/multiplication * @return the minimum or maximum value of a long integer if addition/multiplication of a and b is less than Long.MIN_VALUE or more than Long.MAX_VALUE */ public static long limitLong(long a, long b, long c) { return (((a > 0) && (b > 0) && (c <= 0)) ? Long.MAX_VALUE : (((a < 0) && (b < 0) && (c >= 0)) ? Long.MIN_VALUE : c)); } Tell me if you think this is wrong.

    Read the article

< Previous Page | 1 2 3  | Next Page >