954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please Help me in this.

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

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

lich
Junior Poster in Training
79 posts since May 2008
Reputation Points: -1
Solved Threads: 4
 

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

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.

VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
 

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

sciwizeh
Posting Pro in Training
457 posts since Jun 2008
Reputation Points: 77
Solved Threads: 23
 

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

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

satyapp
Newbie Poster
2 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You