Exception in thread "main" java.lang.NumberFormatException: null

View: New views
7 Messages — Rating Filter:   Alert me  

Exception in thread "main" java.lang.NumberFormatException: null

by Andre Hugo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I am new to the world of textmate and java programming. I have  
searched the Textmate blog and Java Forum for answers but nothing.

The program compiles and runs in the terminal by using javac Bert.java  
and java Bert

But as soon as I want to use Textmate to compile and run the error is  
returned:

Exception in thread "main" java.lang.NumberFormatException: null

Must be textmate problem. Could someone help me?

The short program that is want to compile and run is as follows:

import java.io.*;

public class Bert
{
    public static void main(String[] args) throws IOException
    {
            //Declaring Variables
            int price, downpayment, tradeIn, months, loanAmt;
            double annualInterest, payment, interest;
            String custName, inputPrice, inputDownPayment, inputTradeIn,  
inputMonths, inputAnnualInterest;
            BufferedReader dataIn = new BufferedReader(new  
InputStreamReader(System.in));

           //Get Input from User
                System.out.println("What is your name?  ");
                  custName = dataIn.readLine();
                System.out.print("What is the price of the car?  ");
                  inputPrice = dataIn.readLine();
                System.out.print("What is the downpayment?  ");
                  inputDownPayment = dataIn.readLine();
                System.out.print("What is the trade-in value?  ");
                        inputTradeIn = dataIn.readLine();
                System.out.print("For how many months is the loan?  ");
                  inputMonths = dataIn.readLine();
                System.out.print("What is the decimal interest rate?  ");
                  inputAnnualInterest = dataIn.readLine();

                //Conversions
                price = Integer.parseInt(inputPrice);
                downpayment = Integer.parseInt(inputDownPayment);
                tradeIn = Integer.parseInt(inputTradeIn);
                months = Integer.parseInt(inputMonths);
                annualInterest = Double.parseDouble(inputAnnualInterest);

                //Calculations
                interest = annualInterest / 12;
                loanAmt = price - downpayment - tradeIn;
                payment = loanAmt / ((1 / interest) - ( 1 / (interest * Math.pow(1 +  
interest, months))));

                //Output
                System.out.print("The monthly payment for " + custName + " is $");
                System.out.println(payment);
    }
}




______________________________________________________________________
For new threads USE THIS: textmate@...
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by Alex Podaras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andre,

and welcome :)
The problem is that your program takes some input from the user  
through command line.

You can solve this by opening your Bundle Editor <Control+Alt+Command  
B> and navigate
to the Java>Compile & Run Single File Command, then duplicate the  
command by pressing
the double plus icon at the bottom left, name your new command  
something like "Compile & Run Single File in Terminal"

And insert this:

------
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Compiling “${TM_FILENAME}”…"

cd "$TM_DIRECTORY"
javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -
rtm_parser -eTextMate.parse_errors)
if (($? >= 1)); then exit; fi

# { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
#   echo -e "\nProgram exited with status $?."; }|pre

# # if you want to run the program in Terminal.app
osascript <<EOF
    tell application "Terminal"
       activate
       do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
    end tell
EOF

html_footer
------

This is the same command as "Compile & Run Single File" with some  
commented and uncommented lines for
running your program in terminal after the compilation.

Hope this helps.

Regards,
Alex

On Jan 18, 2008, at 5:42 PM, Andre Hugo wrote:

> import java.io.*;
>
> public class Bert
> {
>   public static void main(String[] args) throws IOException
>   {
>   //Declaring Variables
>   int price, downpayment, tradeIn, months, loanAmt;
>   double annualInterest, payment, interest;
>   String custName, inputPrice, inputDownPayment, inputTradeIn,  
> inputMonths, inputAnnualInterest;
>   BufferedReader dataIn = new BufferedReader(new  
> InputStreamReader(System.in));
>
>   //Get Input from User
> System.out.println("What is your name?  ");
>  custName = dataIn.readLine();
> System.out.print("What is the price of the car?  ");
>  inputPrice = dataIn.readLine();
> System.out.print("What is the downpayment?  ");
>  inputDownPayment = dataIn.readLine();
> System.out.print("What is the trade-in value?  ");
> inputTradeIn = dataIn.readLine();
> System.out.print("For how many months is the loan?  ");
>  inputMonths = dataIn.readLine();
> System.out.print("What is the decimal interest rate?  ");
>  inputAnnualInterest = dataIn.readLine();
>
> //Conversions
> price = Integer.parseInt(inputPrice);
> downpayment = Integer.parseInt(inputDownPayment);
> tradeIn = Integer.parseInt(inputTradeIn);
> months = Integer.parseInt(inputMonths);
> annualInterest = Double.parseDouble(inputAnnualInterest);
>
> //Calculations
> interest = annualInterest / 12;
> loanAmt = price - downpayment - tradeIn;
> payment = loanAmt / ((1 / interest) - ( 1 / (interest * Math.pow(1  
> + interest, months))));
>
> //Output
> System.out.print("The monthly payment for " + custName + " is $");
> System.out.println(payment);
>   }
> }


______________________________________________________________________
For new threads USE THIS: textmate@...
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by Luke Daley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 19/01/2008, at 2:14 AM, Alex Podaras wrote:

> Hello Andre,
>
> and welcome :)
> The problem is that your program takes some input from the user  
> through command line.
>
> You can solve this by opening your Bundle Editor <Control+Alt
> +Command B> and navigate
> to the Java>Compile & Run Single File Command, then duplicate the  
> command by pressing
> the double plus icon at the bottom left, name your new command  
> something like "Compile & Run Single File in Terminal"
>
> And insert this:
>
> ------
> . "$TM_SUPPORT_PATH/lib/webpreview.sh"
> html_header "Compiling “${TM_FILENAME}”…"
>
> cd "$TM_DIRECTORY"
> javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -
> rtm_parser -eTextMate.parse_errors)
> if (($? >= 1)); then exit; fi
>
> # { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
> #   echo -e "\nProgram exited with status $?."; }|pre
>
> # # if you want to run the program in Terminal.app
> osascript <<EOF
>    tell application "Terminal"
>       activate
>       do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
>    end tell
> EOF
>
> html_footer
> ------
>
> This is the same command as "Compile & Run Single File" with some  
> commented and uncommented lines for
> running your program in terminal after the compilation.

Why don't we include this alternative permanently? Also, it really  
should be bound to Apple + R, and the alternative (Run in Terminal)  
could be Apple + Option + R.

I am about to start on a overhaul of the Java grammar too by the way.

LD.

______________________________________________________________________
For new threads USE THIS: textmate@...
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by Andre Hugo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Working now.

Thanks!

On 19 Jan 2008, at 4:28 AM, Luke Daley wrote:

>
> On 19/01/2008, at 2:14 AM, Alex Podaras wrote:
>
>> Hello Andre,
>>
>> and welcome :)
>> The problem is that your program takes some input from the user  
>> through command line.
>>
>> You can solve this by opening your Bundle Editor <Control+Alt
>> +Command B> and navigate
>> to the Java>Compile & Run Single File Command, then duplicate the  
>> command by pressing
>> the double plus icon at the bottom left, name your new command  
>> something like "Compile & Run Single File in Terminal"
>>
>> And insert this:
>>
>> ------
>> . "$TM_SUPPORT_PATH/lib/webpreview.sh"
>> html_header "Compiling “${TM_FILENAME}”…"
>>
>> cd "$TM_DIRECTORY"
>> javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -
>> rtm_parser -eTextMate.parse_errors)
>> if (($? >= 1)); then exit; fi
>>
>> # { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
>> #   echo -e "\nProgram exited with status $?."; }|pre
>>
>> # # if you want to run the program in Terminal.app
>> osascript <<EOF
>>   tell application "Terminal"
>>      activate
>>      do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
>>   end tell
>> EOF
>>
>> html_footer
>> ------
>>
>> This is the same command as "Compile & Run Single File" with some  
>> commented and uncommented lines for
>> running your program in terminal after the compilation.
>
> Why don't we include this alternative permanently? Also, it really  
> should be bound to Apple + R, and the alternative (Run in Terminal)  
> could be Apple + Option + R.
>
> I am about to start on a overhaul of the Java grammar too by the way.
>
> LD.
>
> ______________________________________________________________________
> For new threads USE THIS: textmate@...
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate


______________________________________________________________________
For new threads USE THIS: textmate@...
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by Allan Odgaard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 19 Jan 2008, at 03:28, Luke Daley wrote:

>> [...]
>> This is the same command as "Compile & Run Single File" with some  
>> commented and uncommented lines for running your program in  
>> terminal after the compilation.
> Why don't we include this alternative permanently? Also, it really  
> should be bound to Apple + R, and the alternative (Run in Terminal)  
> could be Apple + Option + R.

Initially I used ⌘B for “Build” commands, but we have since moved  
to ⌘R for all but the bundles that have both a Build + Run and a  
separate Build, so please go ahead and make the change.

Also placing the “Run in Terminal” on ⇧⌘R sounds fine.


______________________________________________________________________
For new threads USE THIS: textmate@...
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by WEBSTA :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Alex!!

Been searching for a way to do this, im not very used to working in the terminal really helped me!!!

Alex Podaras wrote:
Hello Andre,

and welcome :)
The problem is that your program takes some input from the user  
through command line.

You can solve this by opening your Bundle Editor <Control+Alt+Command  
B> and navigate
to the Java>Compile & Run Single File Command, then duplicate the  
command by pressing
the double plus icon at the bottom left, name your new command  
something like "Compile & Run Single File in Terminal"

And insert this:

------
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Compiling “${TM_FILENAME}”…"

cd "$TM_DIRECTORY"
javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -
rtm_parser -eTextMate.parse_errors)
if (($? >= 1)); then exit; fi

# { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
#   echo -e "\nProgram exited with status $?."; }|pre

# # if you want to run the program in Terminal.app
osascript <<EOF
    tell application "Terminal"
       activate
       do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
    end tell
EOF

html_footer
------

This is the same command as "Compile & Run Single File" with some  
commented and uncommented lines for
running your program in terminal after the compilation.

Hope this helps.

Regards,
Alex

On Jan 18, 2008, at 5:42 PM, Andre Hugo wrote:

> import java.io.*;
>
> public class Bert
> {
>   public static void main(String[] args) throws IOException
>   {
>   //Declaring Variables
>   int price, downpayment, tradeIn, months, loanAmt;
>   double annualInterest, payment, interest;
>   String custName, inputPrice, inputDownPayment, inputTradeIn,  
> inputMonths, inputAnnualInterest;
>   BufferedReader dataIn = new BufferedReader(new  
> InputStreamReader(System.in));
>
>   //Get Input from User
> System.out.println("What is your name?  ");
>  custName = dataIn.readLine();
> System.out.print("What is the price of the car?  ");
>  inputPrice = dataIn.readLine();
> System.out.print("What is the downpayment?  ");
>  inputDownPayment = dataIn.readLine();
> System.out.print("What is the trade-in value?  ");
> inputTradeIn = dataIn.readLine();
> System.out.print("For how many months is the loan?  ");
>  inputMonths = dataIn.readLine();
> System.out.print("What is the decimal interest rate?  ");
>  inputAnnualInterest = dataIn.readLine();
>
> //Conversions
> price = Integer.parseInt(inputPrice);
> downpayment = Integer.parseInt(inputDownPayment);
> tradeIn = Integer.parseInt(inputTradeIn);
> months = Integer.parseInt(inputMonths);
> annualInterest = Double.parseDouble(inputAnnualInterest);
>
> //Calculations
> interest = annualInterest / 12;
> loanAmt = price - downpayment - tradeIn;
> payment = loanAmt / ((1 / interest) - ( 1 / (interest * Math.pow(1  
> + interest, months))));
>
> //Output
> System.out.print("The monthly payment for " + custName + " is $");
> System.out.println(payment);
>   }
> }


______________________________________________________________________
For new threads USE THIS: textmate@lists.macromates.com
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate

Re: Exception in thread "main" java.lang.NumberFormatException: null

by WEBSTA :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Alex!!

Been searching for a way to do this, im not very used to working in the terminal really helped me!!!

Alex Podaras wrote:
Hello Andre,

and welcome :)
The problem is that your program takes some input from the user  
through command line.

You can solve this by opening your Bundle Editor <Control+Alt+Command  
B> and navigate
to the Java>Compile & Run Single File Command, then duplicate the  
command by pressing
the double plus icon at the bottom left, name your new command  
something like "Compile & Run Single File in Terminal"

And insert this:

------
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Compiling “${TM_FILENAME}”…"

cd "$TM_DIRECTORY"
javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" -
rtm_parser -eTextMate.parse_errors)
if (($? >= 1)); then exit; fi

# { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
#   echo -e "\nProgram exited with status $?."; }|pre

# # if you want to run the program in Terminal.app
osascript <<EOF
    tell application "Terminal"
       activate
       do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
    end tell
EOF

html_footer
------

This is the same command as "Compile & Run Single File" with some  
commented and uncommented lines for
running your program in terminal after the compilation.

Hope this helps.

Regards,
Alex

______________________________________________________________________
For new threads USE THIS: textmate@lists.macromates.com
(threading gets destroyed and the universe will collapse if you don't)
http://lists.macromates.com/mailman/listinfo/textmate