0

I am getting an error when I run my program in PuTTY but not in Eclipse. I have looked around online to try and find an answer to my issue, but have not been able too.

error:

dataSummary.java.227: inconvertible types
found:    java.lang.Object
required:  int
     int contractIDDisplay = (int) int intr.next();
                                                ^
1 error

and here is the code:

    Iterator itr = set.iterator();
            while (itr.hasNext())
            { //while
                int contractIDDisplay = (int) itr.next();
                if (contractIDDisplay == 1)
                {
                    System.out.printf("%d, %d, %d, %d",contractIDDisplay, monthCounter1, firstDate1, lastDate1);
                    file.format(contractIDDisplay + ", " + monthCounter1 + ", " + firstDate1 + ", " + lastDate1 + ", ");

                }

There is more code before and after the these lines, however I do not think those lines are important. If they are please let me know. "set" is a Set.

Why would Eclipse be able to run my code and PuTTY not? Is there a way I can work around this issue if it cannot be fixed?

Danny
  • 117
  • 1
  • 7

2 Answers2

1

When you run Java from the command line, you might be invoking a different version of Java than the one that runs eclipse. It's not uncommon for a system to have multiple installations of java - over time folks upgrade, patch, whatever and end up with parallel installations. The key question is which version of java is in your PATH when you execute java from the command line?

One way to find out is to run "java --version" from the command line and see if it's what you expect.

You can then compare that to the version referenced in your eclipse.ini file.

schtever
  • 3,210
  • 16
  • 25
  • how can I update my java, I am having a torrid time trying to update the path bc i have 1.7 and 1.6, but I cannot change the compiler on unix (puTTY) to 1.7. – Danny Jun 18 '13 at 13:33
  • @Danny Do you want to update the java that runs eclipse? Or the one you run from the command line? – schtever Jun 18 '13 at 18:42
0

Well I don't know why you're talking about PUTTY but in JAVA int isn't an object Integer is.

Eclipse (well I think it's the compiler) may autocast int to Integer, while the other compiler won't.

Try using Integer instead of int. Then you can call intValue() if the object isn't NULL

If you use Sun, you may be interested by this link also : http://geek.starbean.net/?p=160

Michael Laffargue
  • 10,116
  • 6
  • 42
  • 76