Jump to content

coding in java


Recommended Posts

ok.. i know how to code in java... but i was wondering how do i install the java sdk for fedora core 4.... so that i can compile and also.. wats a good text editor to use? that can compile inside the text editor (like crimson editor) i used crimson editor but i wana try something a little more advance...

Link to post
Share on other sites

Download the Linux RPM version of the J2SE JDK from java.sun.com and install it using 'rpm -ivh <rpm file>'. They distribute the package through a ".rpm.bin" file (to display license stuff), so run 'sh <bin file>' to extract the RPM.

 

For the editor - depends on what you want. I like SciTE. It's a small and lightweight editor that can compile. If you're looking for an IDE check the Eclipse project.

Link to post
Share on other sites

ok so i got SciTE working.. it compiled my code and ran it.. i saw the first screen of my program but when it was suppose to have user input it goes

"Error: your input doesn't represent a valid integer value"

 

why is that?

Link to post
Share on other sites

i dont see any errors..... when i compile.. lol

 

this is wat happens when i compile

>javac CPT.java
>Exit code: 0

 

this is wat happens when i build

>javac CPT.java
>Exit code: 0

 

and this is wat happens when i run

>java CPT
*******************************************************************************

*******	*		   *	  ******  *	***********   *	  ******  *  
*	  *   *		  * *	 *	   *		 *	   * *	 *	   *  
*	   *  *		 *   *	*	   *		 *	  *   *	*	   *  
*	   *  *		*	 *   *	   *		 *	 *	 *   *	   *  
*	   *  *	   *	   *  *	   *   *	 *	*	   *  *	   *   *
*	  *   *	   *	   *  *	   *  *	  *	*	   *  *	   *  *
*******	*	   *	   *  *	   * *	   *	*	   *  *	   * *
*	  *   *	   *********  *	   **		*	*********  *	   **
*	   *  *	   *	   *  *	   *		 *	*	   *  *	   *
*	   *  *	   *	   *  *	   **		*	*	   *  *	   **
*	   *  *	   *	   *  *	   * *	   *	*	   *  *	   * *
*	  *   *	   *	   *  *	   *  *	  *	*	   *  *	   *  *
*******	******  *	   *  ******  *   * *****	*	   *  ******  *   *

*******************************************************************************

Please select a option
1. Play Game
2. Instructions
3. High Scores
4. Exit


Error: your input doesn't represent a valid integer value


Press Enter to continue . . . >Exit code: 0

Link to post
Share on other sites

That's why I said the *relevant* source code, not the entire one. ;) My guess is that you assign the input directly to an integer variable though it gets read as a string. Maybe your Windows JVM automatically converts the input. But show me the source, Luke. :)

Link to post
Share on other sites

here it is the menu part

/Main Menu

	System.out.println ("Please select a option");

	System.out.println ("1. Play Game");

	System.out.println ("2. Instructions");

	System.out.println ("3. High Scores");

	System.out.println ("4. Exit");

	intInput = reader.readInt();

	//Menu Choices

	if (intInput == 1){

		PlayGame();

	}else if (intInput == 2){

		strInstructions();

	}else if (intInput == 3){

		HighScores();

	}else if (intInput == 4){



	}

Link to post
Share on other sites

The data type of your "reader" variable would be interesting, too. I just wrote a small example that *should* work (will test it later, not too much time at the moment):

 

import java.io.*;

public class myinput {
	static public void main(String[] args) {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			int someint = 0;

			System.out.print("Number: ");

			try {
					someint = Integer.parseInt(reader.readLine());
			} catch (IOException e) {
					System.out.println("Input error...");
					System.exit(1);
			}

			System.out.println("Entered "+someint+".");
	}
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...