Results 1 to 18 of 18

Thread: Console Problem

  1. #1
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Console Problem

    Hello,

    Since I'm starting to get bored with the Internet languages (HTML, PHP etc.) i started to learn Java.
    To do so i'm using a Dutch book ("En dan is er Java") which is going pretty well up till now.

    But i just ran into a problem.
    The book started with using JFrame, and i had no problems with using it.
    But at this point it switches to not using any user interface, the console screen (black thingy).
    He writes on it with:

    System.out.println("Random text");

    According to the book this should give the black command/console screen, but on my computer it doesn't.
    I use NetBeans, and it does show the text (Random text) in the output on the bottom of the screen, but i don't get a black screen.
    Does anyone know why i don't get the black screen, or is there another way to get this screen?

    Gr

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Console Problem

    You won't get a command prompt when running the code from your IDE.

    is there another way to get this screen?
    Open a command prompt and run your Java class from there.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Console Problem

    There are step by step instructions for this in Oracle's Tutorial - it is probably a good resource to accompany the book you are reading.

  4. #4
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    Quote Originally Posted by DarrylBurke View Post
    You won't get a command prompt when running the code from your IDE.


    Open a command prompt and run your Java class from there.

    db
    So it doesn't have anything to do with me doing something wrong?
    It just that the writer of the book doesn't use an IDE but uses notepad (for example)?

    Quote Originally Posted by pbrockway2 View Post
    There are step by step instructions for this in Oracle's Tutorial - it is probably a good resource to accompany the book you are reading.
    Thanks, i tried to do so, but couldn't really get the path right.
    But if it isn't a major problem i'm just not going to run in in the command screen.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    Being able to run Java code at a command prompt is quite an important step, since it ensures you understand the concept of classpaths in Java.
    Misunderstanding classpaths is the root of many of the basic bugs we see here, largely because people have learnt using IDEs which hide that side of things from the user.
    Please do not ask for code as refusal often offends.

  6. #6
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    Well, i tried and got the right path.
    But when i try to run an java file he doesn't know what to do with it.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    You can't run a java file.
    You have to compile it first.
    Please do not ask for code as refusal often offends.

  8. #8
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    Okay, i'm trying to do so right now.
    But i got the following:

    C:\USERS\NAME dir

    This shows a list with everything in it, one of these things is the directory Documents.
    But somehow i can't open Documents, when i try: C:\USERS\NAME\DOCUMENTS dir it says it can't find it or something

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    cd is the change directory command.
    so 'cd documents'.

    ETA: Indeed this is all in the link provided above by pbrockway2.
    It leads you by the hand (at least on an XP box).
    Please do not ask for code as refusal often offends.

  10. #10
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    I know, and tried it but i get an error that the directory is invalid.
    I don't know why this is happening, because the directory does exist as i check with the "dir"

    I BTW blacked out my name, and also deleted my dirs, but it's the same everywhere

    Console Problem-2vajkhh.png

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    Just do 'cd documents', since you're already in the directory containing the 'Documents' directory.
    Please do not ask for code as refusal often offends.

  12. #12
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    I tried, but it gives the same error (Invalid directory)

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    Then I have no idea what's wrong with your system.
    Please do not ask for code as refusal often offends.

  14. #14
    Eleky is offline Member
    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Default Re: Console Problem

    Well, then im just going to skip this part.
    My question has been answered, so i think the topic is then pretty much done

  15. #15
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Console Problem

    You're opening a command prompt via Command.com. That probably doesn't recognize Windows' long names, so Documents would be DOCUME~1 (or possibly ~2 / ~3 etc.

    Try opening the command prompt via cmd.exe, that probably recognizes long names.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    They're on Windows 7, where it's just 'Documents'.
    Microsoft shifted everything around.
    And it works with both command.com and command.exe (just tried).
    Please do not ask for code as refusal often offends.

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Console Problem

    it works with both command.com and command.exe (just tried).
    Oh. They seem to have 'upgraded' Command.com for Win7.

    btw you did mean cmd.exe, didn't you?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Console Problem

    Oh yes.
    Whoops.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Help with Console
    By thiagohe in forum Advanced Java
    Replies: 7
    Last Post: 08-01-2011, 01:30 PM
  2. problem with console.readLine()
    By thatguy in forum New To Java
    Replies: 1
    Last Post: 12-14-2008, 07:40 PM
  3. Java console
    By johnjw in forum New To Java
    Replies: 5
    Last Post: 11-28-2008, 12:45 PM
  4. Console Progress Bar
    By new_2_java in forum New To Java
    Replies: 1
    Last Post: 02-16-2008, 02:18 AM
  5. Console doesn't appear!
    By PeteMarsh in forum New To Java
    Replies: 2
    Last Post: 12-17-2007, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •