Results 1 to 12 of 12
  1. #1
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default About File Class

    Hail Guys!
    So, I'm newbie around here, and I have a question about the file class.

    I'm required to use the getParent() method, but I don't know what it does... What's a parent?

    I checked here about it, but I don't understand...

    Can someone explain it to me? Would be very appreciated.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: About File Class

    don't know what it does.
    Use the println method to print out the value that it returns. That should help you understand the relationship between a File and its parent.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    :S Why didn't I think of that?!

    Thanks a lot mate.

  4. #4
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    By the way, diverging from this issue, I tested the program and it popped this exception:
    Exception in thread "main" java.lang.NoClassDefFoundError: p52/java
    Caused by: java.lang.ClassNotFoundException: p52.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at ...


    (By the way, I'm working on windows and ubuntu at the same time, so i did not copy paste, if you're asking, so I did not write everything).

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: About File Class

    The java program could not find the class named in the error message. Where is the definition for the class?
    Is it on the classpath for the java program?
    Its in a package so you need to consider that the p52 folder should be in the folder at the end of the classpath
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    The only class I use is the File class, which is a class from Java itself right? I don't know what I'm possibly doing wrong.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: About File Class

    Is there a class named java in the p52 package?

    i did not copy paste
    You need to show all that you did and all that happened. You have left off useful information to help sole the problem.
    What was the command line that you entered?
    Last edited by Norm; 03-25-2012 at 04:58 PM.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    Hmm.. I'm sending you the code, if you don't mind.

    How do I put the code as java in BBCode? I mean like in a "box".

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: About File Class

    There is nothing I can do with the code.
    You must copy the full contents of the console window that shows what you did to get the error.
    For windows:
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    Ok it's here (sorry if it's not the way to put it):


    ubuntu@ubuntu-laptop:~/Desktop/prog2/aula05$ javac p52.java
    ubuntu@ubuntu-laptop:~/Desktop/prog2/aula05$ java p52.java texto1.txt texto2.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: p52/java
    Caused by: java.lang.ClassNotFoundException: p52.java
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
    Could not find the main class: p52.java. Program will exit.
    ubuntu@ubuntu-laptop:~/Desktop/prog2/aula05$

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: About File Class

    Read the doc for using the java command. It does not take a filename for its operand. It wants a classname
    If you don't understand my response, don't ignore it, ask a question.

  12. #12
    amportugal is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: About File Class

    Omg i got it, I'm so stupid!

    Geez.. I've done this error so many freakin times... Thanks really really for the help!!!

Similar Threads

  1. Replies: 14
    Last Post: 11-25-2011, 04:25 PM
  2. Replies: 7
    Last Post: 10-04-2011, 05:16 AM
  3. Set file number on .class file
    By lmsf in forum Advanced Java
    Replies: 3
    Last Post: 03-24-2010, 06:38 AM
  4. converting java class file to exe file
    By satheeshtech in forum Advanced Java
    Replies: 5
    Last Post: 07-18-2009, 11:47 PM
  5. Replies: 0
    Last Post: 05-13-2008, 06:16 AM

Posting Permissions

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