Simple java game

I'm trying to create a simple game where you specify where you would like to start in a 2d array, then use directional buttons to move the character around. However, rather than store the value of 's', it stores it's value in the character set.. here is my code:
import java.util.*;
public class Map1
     static Scanner console = new Scanner(System.in);
     public static void main(String[] args)
          char character;
          char[][]map = new char[10][10];
          char x, y;
          int printing;
          boolean end = false;
          System.out.println("Indicate where you would like your ship to start by entering a value"
                         + "\nbetween 0 and 9 for x, followed by a value for y");
                         x = console.next().charAt(0);
                         y = console.next().charAt(0);
          System.out.println("The value you entered for x is: " + x);
          System.out.println("The value you entered for y is: " + y);
          map[x][y] = 's';
          System.out.println(map[x][y]);
          System.out.println("Ok, now your directional keys are:"
                         + "\nA moves you to the left, W moves you up,"
                         + "\nD moves you to the right, and S moves you down"
                         + "\nTo end the game and view your map, press x.");
          System.out.println("So now, choose your direction!");
          character = console.next().charAt(0);
          do
               switch(character)
                    case 'a':
                    case 'A':
                         map[x--][y] = 's';
                         break;
                    case 'w':
                    case 'W':
                         map[x][y--] = 's';
                         break;
                    case 's':
                    case 'S':
                         map[x++][y] = 's';
                         break;
                    case 'd':
                    case 'D':
                         map[x][y++] = 's';
                         break;
                    case 'x':
                    case 'X':
                         end = true;
                         System.out.println("Thank you for playing, here is your map.");
                         for (printing = 0; printing < map.length; printing++)
                              System.out.println(map[x][y]);
                         break;
                    default:
                         System.out.println("The value you entered is invalid. Please try again.");
          while (!end);
}

To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the tags it generates.
Declare x and y as int instead of char and use nextInt () instead of next.charAt (0) to read the values inputted. Fragments:        //char x, y;
        int x, y;
        x = console.nextInt ();//.charAt (0);
        y = console.nextInt ();//.charAt (0);That's not all that's wrong, you also need to read the input for directional movement inside rather than before the loop, but try to fix that yourself.
db

Similar Messages

  • How to make "Levels" in simple java game

    I just wanted to know if anybody knew how to make "Levels" in a java game. In my case, it is to change two polygons that are used in the background. I think you have to use an array of some kind, but i dont really know.
    Here is my source, the polygons are by the massive ///////// areas.
    I cut out the majority of the program, because it was too long.
    public class collision extends Applet implements MouseListener,MouseMotionListener
        private  Image rickImage,mazeImage;
       Image Buffer;
       Graphics gBuffer;
       int x, y;
       int[] LeftWallX = {0,204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,0};
       int[] LeftWallY = {500,499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1};
       //int[] PlayAreaX = {204,204,149,149,162,162,243,260,235,259,232,260,230,207,207,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
      // int[] PlayAreaY = {499,402,402,341,324,227,191,157,141,135,123,116,109,86,1,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       int[] RightWallX = {500,500,263,263,245,282,262,274,257,273,250,184,184,170,170,208,216,216};
       int[] RightWallY = {500,0,1,86,103,115,129,138,147,155,201,230,323,340,384,384,402,499};
       boolean mouseInside, collide;
       boolean rolled = false;
       boolean msg = true;
       int sX=204,sY=490,sW=12,sH=9;
       //Declare the rectangles
       Rectangle  movingRect,finshBloc,startBloc,oopsBloc;
       //Declare the polygons
       Polygon leftWall,playerArea,rightWall;
            ///Initiate
            public void init()
                 rickImage = getImage(getDocumentBase(), "rick.jpg");
                 mazeImage = getImage(getDocumentBase(), "maze1.jpg");
                 collide=false;
                 Buffer=createImage(getSize().width,getSize().height);
                 gBuffer=Buffer.getGraphics();
                 rightWall=new Polygon(RightWallX,RightWallY,18);
                 playerArea= new Polygon(PlayAreaX,PlayAreaY,31);
                 leftWall= new Polygon(LeftWallX,LeftWallY,17);
            public void paint(Graphics g)
                 drawStuff();
                 g.drawImage (Buffer,0,0, this);
    */

    I'm not exactly sure in your case what you are trying to accomplish. If all you want to do is make new polygons for your levels then you will simply need a Vector of type level (or polygon). Store multiple levels/polygons in that vector. This can be done many ways, probably the most efficient way would be to create a class Level of sorts and create each level object from there. This way you have all your levels stored into that vector.
    I have made programs where the levels/mazes are randomly generated based on certain parameters (this way you would not need to define any specific level). This can be done inside the Level class and added to the vector so that when a level is randomly generated there are literally infinite possibilities. I would suggest posting all your code or at least a breakdown UML diagram of what is going on in your entire program.

  • Programming my first simple java game

    I want to program a Java Applet called: a knight's tour.
    The game goes as follows:
    When you start the applet a chessboard will be shown.
    When you click on a compartment the knight will appear. Then you've got to click on the next compartment. The applet has to check if this is a "knight move" and if the square has'nt been visited yet.
    You win when you have visited all the compartiments.
    Can anywone help me? The chessboard isn't a problem. But for example, when you click on a point, how can I ask the color of that specific location?
    Thanks for the reaction.

    I very much agree with yawmark. I'm also not really sure how far you want to take this in terms of being an actual chess game, since - to my mind at least - your post is not too clear. Since you mentioned that you did not really understand Java very well, I again 2nd what yawmark said. Still, since you were considerate and frank, I had a few minutes and so coded up what I meant in my prior post. As I said, I'm sure there are better approaches, but since I'm not really sure where you're headed with this, I thought I'd post the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ChessGame  extends JFrame {
      private boolean isRed;
      private JLabel  jl;
      public ChessGame() {
        super( "ChessGame" );
        Container c = this.getContentPane();
        JPanel jp = new JPanel();
        jp.setLayout( new GridLayout( 8, 8, 0, 0 ) );
        for ( int idx = 1; idx < 65; idx++ ) {
          jp.add( buildJButton() );
          if ( idx % 8 == 0 ) isRed = !isRed;
        c.add( jp );
        jl = new JLabel( "click on a square" );
        c.add( jl, BorderLayout.SOUTH );
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setBounds( 100, 100, 500, 500 );
        setVisible( true );
      public JButton buildJButton() {
        final JButton jb = new JButton( "" );
        jb.setBorderPainted( false );
        if ( isRed ) jb.setBackground( Color.red );
        else         jb.setBackground( Color.black );
        isRed = !isRed;
        jb.addActionListener( new ActionListener() {
          public void actionPerformed( ActionEvent ae ) {
            if ( ( ""+jb.getBackground() ).startsWith( "java.awt.Color[r=0" ) )
              jl.setText( "black" );
            else
              jl.setText( "red" );
        return( jb );
      public static void main( String[] argv ) {
        new ChessGame();
    }HTH

  • Help Making a SIMPLE JAVA GAME *TINY GLITCH*

    got a tinnnny glitch and ive tried everything to get it to work, but so far no luck.
    Heres what my program does:
    1. Aliens spawn at top left (top 4 rows) and move to the right and dissapear (DONE)
    2. Shooting rectangle at bottom middle (moves left and right) and shoots bullets (DONE)
    3. When bullets make contact with alien the alien dissapears (DONE)
    4. When you shoot 20 bullets game over (DONE)
    5. When all the aliens fly by the screen game over (DONE)
    GLITCH
    1. When an alien is killed any bullet that goes over the exact same spot of collision the bullet dissapears! +so does an alien going over same collision spot
    MISSING
    1. Score, every alien kill + 10 CANNOT get a working score funtion to +10 fo every alien successfully hit :(
    My SRC jus copy and paste and compile, any help appreciated
    http://www.geocities.com/porche_masi/Assignment3.txt
    //ignore spelling mistakes in comments and outputs lol
    ive spent way to many hours over these 2 stupid problems, hope new eyes can spot the problem

    I'm not going to look at your code, but it sounds like when you're killing things you're not removing them from your future calculations. So if an alien is killed, it should either be removed from the list of aliens, or a "dead" flag should be set on it which causes it to be ignored in future calculations.
    edit I did look at your code actually, and that is a really, really bad use of multithreading. You shouldn't just create a new thread every time a bullet is fired. You should maintain a list of bullets, have the main thread drive the UI, and have a secondary thread to update the game logic (recalculate collisions, etc).
    Edited by: endasil on Nov 21, 2007 3:16 PM

  • Simple java pathfinder game

    Hi
    Is any1 willing to make me a simple java pathfinder game in return for some money? details will be given on request...

    Sod off and do your own homework.

  • JAVA Game DEV

    Does anyone know of a site which will walk a total newbie through making a very simple game in Java. It doesn't matter how crappy the game is, just something to get the newbie started.
    The website is for me :)
    Thanks,
    Christopher Gillis

    I recomend books like "Black Art of Java Game Programming". Although it is old. It is still very relevant.
    The sites that I learnt from are:
    http://www.gamejug.org/tutorials/
    http://www.electricfunstuff.com/jgdc/tutorials/jgdc_tutorials.htm
    http://blazinggames.com/books/jgd/ch01/page02.html
    They are good sites for amatures.
    I also found insparation and some code at:
    http://www.javaonthebrain.com
    Hope that helps!!

  • Java game AI

    Hi there, I am currently creating a battleship game which allows you to play against a computer or a human or run the game as a spectator watching the computer battle its own AI. I am having trouble finding an efficient way to program the AI when I hit a ship on the opponents map.
    Current logic: I hit an enemy ship and add all the possible directions into a queue and resolve them in order, up down left right. If there is an 'o' (miss) or 'x' (hit), currently in one of the suggested directions, it will be removed (since it has already been searched) and move on to the next coordinate.
    Problem: The AI is extensive in it's checking. It finds a long ship, 10 char long, and checkes all around the the ship making sure nothing else is there. Although this method is very accurate, it takes too many turns to verify that it has found the whole ship, therefore losing almost all the time.
    Any ideas?
    -Thanks in advance
    EDIT: Sample from AI vs AI.
    x = hit
    o = miss
    Computer2's Map
    0123456789
    0 .......xxo
    1 .ooo..o.o.
    2 ....o.....
    3 ..........
    4 .....ooooo
    5 ...ooooxxo
    6 .ooxxxxxo.
    7 .oooooooo.
    8 .......o..
    9 .o........
    Edited by: Krytical on Jul 15, 2009 2:55 PM

    I think you are not putting enough into it.
    AI is hard, no matter how simple the game may seem. I have written about 16 games (I might have missed one or two in a hasty count) and worked on a couple open source game projects. Of those 16, 2 of them include an option to play against the computer, i.e. they have a good enough AI. The rest are all strictly multiplayer or single player with no opponents (simulations). Of those two, both are also and where first multiplayer games. That is because until I can play a game enough to fully understand it strategically (even though I wrote it), it is impossible to write a working AI.
    So here is my advice, play a few dozen games against other players, the more different people you play against the better. Jot down your strategies in every situation, and ask you opponent if they would be kind enough to do likewise (it helps to tell them it is for writing an AI, otherwise they think you are just trying to learn their secrets for the next time you play). Then try out some of the strategies you get from others and see if you understand it, when it is best to use that strategy, and how well it works.
    At this point, you should try to code several of those strategies and see how well the computer does with it. Then code a way for the computer to weigh the possible effectives of the different strategies and randomly choose between them based on the weighted scale. As in, if start A is 5 times more likely to succeed than strat B in situation X then the computer should have 5 times more likelihood of choosing strat A over strat B for situation X.
    As a starting point, here is my strat for battleship in a way that should help with how to code it. I always look at which direction has the longest distance to where I have previously fired. But I also limit it to 4 spaces as that is the length of the longest ship (plus the one hit). So if I choose say F6 (isn't it letters across the top?) and get a hit, then I look around F6. Looking down I have already gotten a miss on F9 leaving 2 blank spaces. Looking left I have recorded a miss on A6, leaving 4 spaces that way. Looking up I have a miss on F5, so there is definately not one that way and this makes it less likely the boat runs north and south (up and down). To the right the nearest shot was a hit on a boat I already sunk but it is 7 spaces away, so I exceed the limit and reduce it to 4 spaces. So what do we have, 2 spaces down, no spaces up and 4 spaces to both the left and the right. At this point I am just going to randomly choose to go left or right and keep going that way until I get a miss or my opponent announces I sunk a ship, if a miss with no sinking I go the other way until said declaration. Should I get a miss on both sides without an additional hit then I will re-evaluate and since the only way left to go in that case would be down, that is how I would go. If I got a hit going either way but missed on both sides then I know I have two ships and I simply put the new hit on the back burner until I have sunk the first.
    Now this should all be relatively easy to code and should make the AI much more formidable. But there is actually far more I do when playing that game. For example, if the 5 length ship has already been sunk and the longest left is 4 length, then I only go 3 blank spaces each way in weighing my options. Similarly if the 2 length ship and both 3 length ships are sunk then I first check to ensure there is a total of at least 4 spaces along either axes (there must be on at least one of them). This will be a little more coding work, but will make the computer AI even more robust and formidable.
    If I was playing against your AI I would always place my ships from left to right, because I know the AI is then always going to waste at least 2 shots whenever it gets a hit. In AI the more unpredictable the AI is the better, this is why it is important to keep things random, and give the computer as many strategy choices as possible to weigh and then semi-randomly choose from.
    Also, this is the wrong place on these forums for this question, there is actually a java games section here, I think it is under other. Also there is actually a fairly active java game forum, but I don't recall the url for it atm. You will have far better chances of getting a response in one of those more appropriate places.
    JSG

  • How to pass a HTTP request from a simple java class

    Is it possible to pass an HTTP request from a simple java class.if yes how?

    Is it possible to pass an HTTP request from a simple
    java class.if yes how?If you're talking about creating a HttpRequest object and passing it to a servlet, that would be a red flag to me that your design is flawed. You shouldn't have to do that - the application server (Tomcat, Weblogic, etc) should be the only thing that has to worry about creating that kind of object and passing it to you.

  • How do I call a simple java class from a bpel process?

    Hi.
    In JDeveloper 10.1.4.3.0 I've created a simple java class that does an ftp get operation followed by an unzip. The class uses some 3rd part libraries (jars).
    I want to use a simple bpel process to schedule a daily execution of this java class, and deploy it all to our SOA-server, - and was looking into using the <bpelx:exec> function.
    The java class and the bpel process is all stored in the same JDeveloper project.
    How do I put this together so that both my java class and the necessary jars are available to the bpel process?
    I've looked into the JavaExecSample.bpel, and it's says something about "...the class com.otn.samples.javaexec.CreditCalculator is locally packaged with this BPEL process".
    How do I do that?
    Can I make it and test it all locally from my workstation (only JDeveloper installed, I guess there's nothing that can execute the bpel code?), or do I have to compile class etc (make war-file?) and deploy to SOA server (BPEL-INF/lib or classes?) before anything can be tested?
    (I guess all this is simple, once you know how, but being a newbie to this I need a shove in the right direction :-)
    Regards,
    -Haakon-

    To create a java class and dependent jars inside the BPEL process project you need to do the following:
    1. Right click on your BPEL process project and select New and then Java Class from the Items.
    2. Make the BPEL process project, JDeveloper would compile the java classes and add them into the BPEL suite case jar, see the output folder and check the BPEL suite case jar file for java classes and dependent jars.
    You can test your Java classes from JDeveloper IDE, no need to deploy the classes on SOA server. When you make the BPEL project it compiles .bpel files and Java classes. You can test your classes once .bpel file and java classes compiled successfully.
    Regards,
    Dharmendra
    http://soa-howto.blogspot.com

  • How can I download java game?

    Hi everyone, sorry for my english, it is not my native language.
    I have Game.Jar file, which is java game for Nokia ,and I uploaded this file into database.
    Now I have a filed, type of byte[] (array of bites)
    next, I generate URL like http://site.com/getfile.xxx?id=10, and then user go to this URL via WAP, and trying to send him byte[] array with java game data.
    But I don't know which Content-Type i must send :(
    I trying to send Content-Type: application/jar , but after downloading game into mobile phone, the game doesnt open :(((
    please help me!

    excuse me, it's actually application/java-archive
    This works for me (PHP) but unfortunately you have to rename the downloaded file to .jar:
    <?php
    $file = fopen("MimeTest.jar","r");
    header("Content-Type: application/java-archive");
    $text = fread($file,filesize("MimeTest.jar"));
    print $text;
    fclose($file);
    ?>You can try it out here: http://woogley.net/misc/MimeTest.php
    Download that and rename it to .jar and see if the data stayed in tact..

  • Efficiency Question: Simple Java DC vs Used WD Component

    Hello guys,
    The scenario is - I want to call a function that returns a FileInputStream object so I can process it on my WD view. I can think of two approaches - one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there. Or create another WD DC that exposes the value (as binary) via component interface.
    I'm leaning on the simple Java DC approach - its easier to create. But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency? (Though I doubt) Or is it just a 'best/recommended practice' approach?
    Thanks!
    Regards,
    Jan

    Hi Jan
    >one is to simply write a simple Java DC that does so and just use it as a used DC so I can call the functionality from there
    Implemented Java  API for the purpose mentioned in your question is the right way, I think. The Java API can be even located in the same WebDynpro DC as your WebDynpro components. There is not strongly necessity to put it into separate Java DC.
    >Or create another WD DC that exposes the value (as binary) via component interface
    You should not do this because in general WD components' purpose is UI, not API. Implementing WD component without any UI, but with some component interface has very-very restricted use cases. Such WD component shall only be a choice in the cases when the API is WebDynpro based and if you have to strongly use WebDynpro Runtime API in order to implement your own API.
    If your API does not require WebDynpro Runtime API invocations or anything else related to WebDynpro then your choice is simple Java API.
    >But I'm just curious on what would be the Pro-side (if there's any) if I use the WD Component interface approach? Is there a plus for the efficiency?
    No. Performance will be better in simple Java API then in WebDynpro component interface. The reason is the API will not pass thought heavy WebDynpro engine.
    BR, Siarhei

  • Problem while executing simple java program

    Hi
    while trying to execute a simple java program,i am getting the following exception...
    please help me in this
    java program :import java.util.*;
    import java.util.logging.*;
    public class Jump implements Runnable{
        Hashtable activeQueues = new Hashtable();
        String dbURL, dbuser, dbpasswd, loggerDir;   
        int idleSleep;
        static Logger logger = Logger.getAnonymousLogger();      
        Thread myThread = null;
        JumpQueueManager manager = null;
        private final static String VERSION = "2.92";
          public Jump(String jdbcURL, String user, String pwd, int idleSleep, String logDir) {
            dbURL = jdbcURL;
            dbuser = user;
            dbpasswd = pwd;
            this.idleSleep = idleSleep;
            manager = new JumpQueueManager(dbURL, dbuser, dbpasswd);
            loggerDir = logDir;
            //preparing logger
            prepareLogger();
          private void prepareLogger(){      
            Handler hndl = new pl.com.sony.utils.SimpleLoggerHandler();
            try{
                String logFilePattern = loggerDir + java.io.File.separator + "jumplog%g.log";
                Handler filehndl = new java.util.logging.FileHandler(logFilePattern, JumpConstants.MAX_LOG_SIZE, JumpConstants.MAX_LOG_FILE_NUM);
                filehndl.setEncoding("UTF-8");
                filehndl.setLevel(Level.INFO);
                logger.addHandler(filehndl);
            catch(Exception e){
            logger.setLevel(Level.ALL);
            logger.setUseParentHandlers(false);
            logger.addHandler(hndl);
            logger.setLevel(Level.FINE);
            logger.info("LOGGING FACILITY IS READY !");
          private void processTask(QueueTask task){
            JumpProcessor proc = JumpProcessorGenerator.getProcessor(task);       
            if(proc==null){
                logger.severe("Unknown task type: " + task.getType());           
                return;
            proc.setJumpThread(myThread);
            proc.setLogger(logger);       
            proc.setJumpRef(this);
            task.setProcStart(new java.util.Date());
            setExecution(task, true);       
            new Thread(proc).start();       
         private void processQueue(){       
            //Endles loop for processing tasks from queue       
            QueueTask task = null;
            while(true){
                    try{
                        //null argument means: take first free, no matters which queue
                        do{
                            task = manager.getTask(activeQueues);
                            if(task!=null)
                                processTask(task);               
                        while(task!=null);
                    catch(Exception e){
                        logger.severe(e.getMessage());
                logger.fine("-------->Sleeping for " + idleSleep + " minutes...hzzzzzz (Active queues:"+ activeQueues.size()+")");
                try{
                    if(!myThread.interrupted())
                        myThread.sleep(60*1000*idleSleep);
                catch(InterruptedException e){
                    logger.fine("-------->Wakeing up !!!");
            }//while       
        public void setMyThread(Thread t){
            myThread = t;
        /** This method is only used to start Jump as a separate thread this is
         *usefull to allow jump to access its own thread to sleep wait and synchronize
         *If you just start ProcessQueue from main method it is not possible to
         *use methods like Thread.sleep becouse object is not owner of current thread.
        public void run() {
            processQueue();
        /** This is just another facade to hide database access from another classes*/
        public void updateOraTaskStatus(QueueTask task, boolean success){
            try{         
                manager.updateOraTaskStatus(task, success);
            catch(Exception e){
                logger.severe("Cannot update status of task table for task:" + task.getID() +  "\nReason: " + e.getMessage());       
        /** This is facade to JumpQueueManager method with same name to hide
         *existance of database and SQLExceptions from processor classes
         *Processor class calls this method to execute stored proc and it doesn't
         *take care about any SQL related issues including exceptions
        public void executeStoredProc(String proc) throws Exception{
            try{
                manager.executeStoredProc(proc);
            catch(Exception e){
                //logger.severe("Cannot execute stored procedure:"+ proc + "\nReason: " + e.getMessage());       
                throw e;
         *This method is only to hide QueueManager object from access from JumpProcessors
         *It handles exceptions and datbase connecting/disconnecting and is called from
         *JumpProceesor thread.
        public  void updateTaskStatus(int taskID, int status){       
            try{
                manager.updateTaskStatus(taskID, status);
            catch(Exception e){
                logger.severe("Cannot update status of task: " + taskID + " to " + status + "\nReason: " + e.getMessage());
        public java.sql.Connection getDBConnection(){
            try{
                return manager.getNewConnection();
            catch(Exception e){
                logger.severe("Cannot acquire new database connection: " + e.getMessage());
                return null;
        protected synchronized void setExecution(QueueTask task, boolean active){
            if(active){
                activeQueues.put(new Integer(task.getQueueNum()), JumpConstants.TH_STAT_BUSY);
            else{
                activeQueues.remove(new Integer(task.getQueueNum()));
        public static void main(String[] args){
                 try{
             System.out.println("The length-->"+args.length);
            System.out.println("It's " + new java.util.Date() + " now, have a good time.");
            if(args.length<5){
                System.out.println("More parameters needed:");
                System.out.println("1 - JDBC strign, 2 - DB User, 3 - DB Password, 4 - sleeping time (minutes), 5 - log file dir");
                return;
            Jump jump = new Jump(args[0], args[1], args[2], Integer.parseInt(args[3]), args[4]);
            Thread t1= new Thread(jump);
            jump.setMyThread(t1);      
            t1.start();}
                 catch(Exception e){
                      e.printStackTrace();
    } The exception i am getting is
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe
    Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820] Please help me.....
    Thanks in advance.....sathya

    I am not willing to wade through the code, but this portion makes me conjecture your using an Oracle connect string instead of a class name.
    java.lang.NoClassDefFoundError: jdbc:oracle:thin:@localhost:1521:xe

  • What's wrong with this simple java file

    I am learning java input methods. When I tried to compile the below simple java file, there were two errors.
    import java.io.*;
    public class MainClass {
       public static void main(String[] args)  {
        Console console = System.console();
        String user = console.readLine("user: ");
        System.out.println(user);
    }The compiler errors:
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : class Console
    location: class MainClass
    Console console = System.console();
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : method console ()
    location: class java.lang.System
    Console console = System.console();
    ^
    2 errors
    Could anyone take a look and shed some lights on this?

    I have changed to "import java.io.Console;" but this below errors:
    h:\java\MainClass.java:1: cannot resolve symbol
    symbol : class Console
    location: package io
    import java.io.Console;
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : class Console
    location: class MainClass
    Console console = System.console();
    ^
    h:\java\MainClass.java:5: cannot resolve symbol
    symbol : method console ()
    location: class java.lang.System
    Console console = System.console();
    ^
    3 errors
    -----------

  • How to Deploy a Simple Java Web service in Oracle E Business Suite Server

    Hi,
    I have created a simple Java webservice using Jdev11g.
    I am able to Test the Webservice using Jdev11g itself.
    How Can i migrate the same to Oracle E Busienss Suite( - 9iAS ) so that webservice clients connect to 9iAS instead of my local machine
    Thanks,
    Gowtam.

    Hi Sudhakar,
    If you are used to working with ant then you can very well use eclipse to deploy your web service.
    You would usually have the ant script in the source root working directory. From eclipse if you select the build file from the navigator view and right click you will see a run ant option in the pop up menu.
    Select that option and you would be able to see each targets with a checkbox select option. So define each target maybe one for wsdl2java conversion, one for compilation and one for deploying your web services. You can either make all of them run by having depends option on or you can run them individually as it takes your fancy.
    I am not sure about debugging a web service yet.
    Hope this helps
    Aviroop
    The truth is out there? Does anyone know the URL?

  • How to  get the profile object in simple java class  (Property accessor)

    Hi All,
    Please guide me how to get the profile object in simple java class (Property accessor) which is extending the RepositoryPropertyDescriptor.
    I have one requirement where i need the profile object i.e i have store id which is tied to profile .so i need the profile object in the property accessor of the SKU item descriptor property, which is extending RepositoryPropertyDescriptor.
    a.I dont have request object also to do request.resolvename.
    b.It is not a component to create setter and getter.It is simple java class which is extending the RepositoryPropertyDescriptor.
    Advance Thanks.

    Iam afraid you might run into synchronization issues with it. You are trying to get/set value of property of a sku repository item that is shared across various profiles.
    Say one profile A called setPropertyValue("propertyName", value).Now another profile B accesses
    getPropertyValue() {
    super.getPropertyValue() // Chance of getting value set by Profile A.
    // Perform logic
    There is a chance that profile B getting the value set by Profile A and hence inconsistency.
    How about doing this way??
    Create PropertyDescriptor in Profile (i.e user item descriptor), pass the attribute CustomCatalogTools in userProfile.xml to that property.
    <attribute name="catalogTools" value="atg.commerce.catalog.CustomCatalogTools"/>
    getPropertyValue()
    //You have Profile item descriptor and also storeId property value.
    // Use CustomCatalogTools.findSku();
    // Use storeId, profile repository item, sku repository item to perform the logic
    Here user itemdescriptor getPropertyValue/setPropertyValue is always called by same profile and there is consistency.
    -karthik

Maybe you are looking for

  • How to SHAPE(mask) tween in Photoshop?

    Hello,         please tell me how to SHAPE (mask, path) TWEEN in Photoshop? Flash is capable of Shape Tweening but does not have Photoshops tools or esp. Channel Operations for precise mask edits. Hope to talk soon, Jeff

  • Have to use GET LINK feature to open pics with BB8330

    Can anyone help with this? Purchased 2 new BB8330 curve through best buy (sprint is the carrier) at the same time, one for me and the wife. She gets her MMS pics right away, I have to use the link to go and view the picture. Called help desk from spr

  • My home button doesn't work.

    I have never dropped my ipod before but my home button doesn't work anymore. Will they replace my ipod or would I have to buy a new one?

  • Creating a Fax sheet that auto-populates

    Hi: I am trying to create a fax sheet that has a list of companies in a drop down menu.  When a user selects a company, I want the phone field to auto-populate with the phone number.  I am using Acrobat X.  Any help would be greatly appreciated. Than

  • Installation Disk Backup

    What is the best way to make a backup copy of the Leopard Installation Disk without using a double layer drive? Thanks.