Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between command line tool compiling and IDE compiling Java

im new to java, ROOKIE... i was doing arraylist example and i compiled it on IDE it worked perfectly, i did that example on CMD it gave me an error

Note: Practice.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

so i used my googling power and googled everything, i found a answer,

by the way this is the code im talking about...

     import java.util.*;
     public class Practice{
     public static void main(String[] args){
     ArrayList mylist = new ArrayList();
     mylist.add("Maisam Bokhari");
     mylist.add("Fawwad Ahmed");
     mylist.add("Ali Asim");
     mylist.add("Maheen Hanif");
     mylist.add("Rimsha Imtiaz");
     mylist.add("Mugheer Mughal");
     mylist.add("Maaz Hussain");
     mylist.add("Asad Shahzada");
     mylist.add("Junaid Khan");
     System.out.println("Name of the student: "+mylist);
    }
}

it work perfectly on IDE (netbeans) but it gave those 2 errors on cmd

many people all over the internet and stackoverflow said that define the data type when creating an ArrayList object

ArrayList< String > mylist = new ArrayList<>();

i did this and it worked perfectly on CMD too... :)

now my question is this which i cant find on the internet

what is the difference between IDE compiling and command line tools compiling?

( i remember when i used to compile my C code in turboC and when i shifted to code::blocks i had to change some code to adjust the compiler , is this same thing ? but java was platform independent )

like image 623
ramb0 Avatar asked Aug 30 '26 16:08

ramb0


1 Answers

One reason for the difference is that your IDE might be using a different version of java than your command line compiler. You would see this if your Netbeans IDE uses java 1.4 or older and your command line uses 1.5 or newer.

like image 160
Ross H Mills III Avatar answered Sep 01 '26 07:09

Ross H Mills III



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!