• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code compiles fine in Eclipse, but not with command-line javac  RSS feed

 
Aditya Jha
Ranch Hand
Posts: 227
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm facing a weird issue where a certain piece of code is compiling fine on Eclipse, but giving errors (not even warnings) when I try to compile it using command-line javac.

I checked the JDK used in both cases, along with the JDK compliance and JDK arguments settings in both cases, and they are exactly similar. The JDK used is 1.6.0_21 in both cases.

Here's the code:



and



This code looks fine in Eclipse without any errors or warnings at all. However, when I try to compile GenericStaticTest on command-line, I get:


adityj\temp\GenericStaticTest.java:10: ')' expected
return (GenericStaticTest<T2>.Sub) obj;
^
adityj\temp\GenericStaticTest.java:10: ';' expected
return (GenericStaticTest<T2>.Sub) obj;
^
adityj\temp\GenericStaticTest.java:10: illegal start of expression
return (GenericStaticTest<T2>.Sub) obj;
^
3 errors


If I remove the <T2> part in the complaining area (which I also think would be the right way of coding), I get a warning on Eclipse saying 'GenericStaticTest.Sub is a raw type. References to generic type GenericStaticTest<T>.Sub should be parameterized'. Also, the command-line compiler does compile the code, but also generates an Xlint:unchecked warning:


adityj\temp\GenericStaticTest.java:10: warning: [unchecked] unchecked conversion

found : adityj.temp.GenericStaticTest.Sub
required: adityj.temp.GenericStaticTestInterface<T2>
return (GenericStaticTest.Sub) obj;
^
1 warning


Any ideas why this could be happening? Thanks in advance.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you compile the interface from the command line first? I, too, compiled this code successfully from Eclipse but got the following warning:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!