Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: quick question

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default quick question

    Greetings,

    I'm completely new to programming and thought I might give java a try.

    I'm trying to write a program that gets a password from a user. It will then be tested against a password stored in a string. I want to use a while
    loop that will repeat until the user gets the correct password.

    When I use an online compiler, it doesn't execute for me. Am I on the right path? The code is as follows...

     
    import javax.swing.JOptionPane;
    public class Password
    {
    	public static void main(String[] args) 
    	{ 
    		String yourpass, mypass;
    		mypass = "happy";
    		boolean b = false;
     
     
     
     
    		 while(!b)
     		 {
    			yourpass = JOptionPane.showInputDialog(null, "Enter password: ");
     
    			if(yourpass.equals(mypass))
    		  {
    			JOptionPane.showMessageDialog(null, "Correct password!");
    			b = true;
     
    		  }
    		  else
    		  {
    			JOptionPane.showMessageDialog(null, "Incorrect password!");
     
    	      }
            }
        }
    }
    Thank you for any sugggestions,
    Jim


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: quick question

    Why on earth do you use an online compiler? Compile it yourself. BTW, it looks OK, apart from the indentation.

  3. #3
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: quick question

    Just ran your code in Eclipse and it worked perfect. What online compiler are you using and what kind of errors are you getting?
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: quick question

    I was using compileonline and it was hanging on the executing of the file.

    is my indentation okay... outside of the curlys lining up?

    I will look at eclipse. Is this the one I install?

    Eclipse IDE for Java EE Developers.

    Thank you for the replies.

  5. #5
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: quick question

    You just need a JDK and an editor (e.g. Notepad++) to start. Learning to use eclipse is a completely different thing. You should be able to compile and run from the command line, learn the pitfalls of path, classpath and packaging, before using an IDE. It hides all that stuff, that you sooner or later have to know.

  6. #6
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: quick question

    Complete shenanigans! I've been a software engineer for 6 years and have never coded via command line. And furthermore, learning an IDE like Eclipse is crazy easy, there are many tutorials on the basics on youtube. I agree learning the basics of paths and packaging are a good idea, but that's not typically something you learn when you first start programming.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

Similar Threads

  1. [SOLVED] Quick little question
    By geezlouise in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 24th, 2013, 11:28 PM
  2. Quick question
    By l1nk3 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 24th, 2012, 02:02 PM
  3. Quick Question
    By sird00dguyman in forum Java Theory & Questions
    Replies: 2
    Last Post: August 4th, 2011, 06:14 PM
  4. Another Quick Question
    By Jacksontbh in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 1st, 2011, 07:18 AM
  5. Hi, quick question
    By curras in forum Member Introductions
    Replies: 1
    Last Post: March 21st, 2011, 03:21 PM