Here is my code


import java.io.*;

class Add
{
public static void main (String args[] ) throws IOException;
{
BufferedReader br=new BufferedReader( new InputStreamReader (System.in));

System.out.println("Enter the value of X:");
int x=Integer.parseInt(br.readLine());

System.out.println("Enter the Value of Y:");
int y=Integer.parseInt(br.readLine());

int z=x+y;

System.out.println("\n\nValue of X + Y = " +z);


}

}


when i try to compile in command prompt.

first i have to set the path. then i typed javac Add.java

then it says

javac : file is not found : add. java
Usage : javac <options><source files>

please help me. if anyone can explain whats going on. im a mega noob in java. help me

Here is my code


import java.io.*;

class Add
{
public static void main (String args[] ) throws IOException;
{
BufferedReader br=new BufferedReader( new InputStreamReader (System.in));

System.out.println("Enter the value of X:");
int x=Integer.parseInt(br.readLine());

System.out.println("Enter the Value of Y:");
int y=Integer.parseInt(br.readLine());

int z=x+y;

System.out.println("\n\nValue of X + Y = " +z);


}

}


when i try to compile in command prompt.

first i have to set the path. then i typed javac Add.java

then it says

javac : file is not found : add. java
Usage : javac <options><source files>

please help me. if anyone can explain whats going on. im a mega noob in java. help me

I assume you called your file Add.java, right? I get a different error when I try to compile your code. Are you sure you didn't make a typo and you have your path set correctly? Try this. Create a new file called helloworld.java and put this in it:

public class helloworld
{
    public static void main()
    {
        System.out.println("Hello World");
    }
}

Then at the command line type "

javac helloworld.java

then

java helloworld

You should get no errors and the screen should display "Hello World". Your error looks like a simple typo possibly.

Did you navigate to the directory in command prompt? cd c:\DIRECTORY\blabla...Add.java or cd DIRECTORY_IN_CURRENT_DIRECTORY and then javac Add.java

Here is my code


import java.io.*;

class Add
{
public static void main (String args[] ) throws IOException;
{
BufferedReader br=new BufferedReader( new InputStreamReader (System.in));

System.out.println("Enter the value of X:");
int x=Integer.parseInt(br.readLine());

System.out.println("Enter the Value of Y:");
int y=Integer.parseInt(br.readLine());

int z=x+y;

System.out.println("\n\nValue of X + Y = " +z);


}

}


when i try to compile in command prompt.

first i have to set the path. then i typed javac Add.java

then it says

javac : file is not found : add. java
Usage : javac <options><source files>

please help me. if anyone can explain whats going on. im a mega noob in java. help me

ur code is running fine.
but make some change
make ur class public
and set classpath=%classpath%;.;
and then run ur code.it will run fine...

satya prakash
pune,india

This article has been dead for over six months. Start a new discussion instead.