Why do i get a compile error?

Hello everyone, I am new to programming the issue which I am facing is like when I run the code on codechef IDE it gives the result of “Successfully Executed” but when I try to Submit it it gives me Compilation error.

Below is my code:

import java.util.;
import java.lang.
;
import java.io.*;

class Question_A{

    public static void main(String[] args) throws IOException
    {
       try {
    	   int number;
	        Scanner sc = new Scanner(System.in);
	        
	        number = sc.nextInt();
	          while(number != 42)
	          {
	              System.out.println(number);
	              number = sc.nextInt();
	          }
	          
       }
	          catch(Exception e){
	        	  
	          } 
	       
       }
    }

Please help me

While submitting i got the compile time error why so.
/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.;
import java.util.Scanner.
;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here

	int rs,prs,brs,t;
	
Scanner s = new Scanner(System.in);
t=s.nextInt();

	if(0<t)
	{
	    if(t<101){
	        
	    	rs=		s.nextInt();
	prs=	s.nextInt();
	brs=		s.nextInt();
	if(rs>=prs)
	System.out.println("He can eat pizza");
	
	else if(prs>rs)
	{
	    if(rs>brs)
	    {
	        System.out.println("He can not buy a PIZZA but can buy a BURGER for his dinner.");
	    
	}
	
	else
	System.out.println("he can not buy anything and remains hungry :");
	}}
}

}

You can use online compiler for better result or you can use Vs code editor for better experience …

use EditPlus as another alternative for all languages, it is same as Turbo not allowing any type of predefined or anything. It is the best platform for beginners to gain all knowledge and not get habituated to pre-made foods.