Results 1 to 10 of 10

Thread: java assignment

  1. #1
    drewjordan is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default java assignment

    i am doing a java assignment... first task was to scan some documents and store each as a separate file, give each document a ref no and construct a short abstract.. i have done this and abstract created as a .txt file; then i coded a scanneddocuments.java and a tester.java.. they are both error free however when i try to run them they both give me 'missing main method please define the main method as: public static void main(string[] args);' but when i type it in the code and check for errors the code gives me 'missing method body, or declare abstract' .... what am I doing wrong?? (these are coded on textpad and when i run it on netbeans, because i have to use netbeans to create a UI to retrieve and display a selected document together with its abstract, it still gives me the same error)... help is greatly appreciated

  2. #2
    Join Date
    Jan 2010
    Posts
    19
    Rep Power
    0

    Default Re: java assignment

    Maybe this site can help you:
    main() Method - Java Execution Entry Point

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java assignment

    If you're getting errors, you probably need to show your code and the error messages, right? We're horribly bad at reading minds or guessing what your code or error messages look like sight unseen.

  4. #4
    drewjordan is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: java assignment

    i have managed to solve the error on the scanneddocuments.java thanks to the link provided by Gilvan Justino... but still have a problem with this one... sorry for not showing the code and errors properly before...
    java assignment-tester.jpg
    i hope i attached it properly...
    thanks

  5. #5
    drewjordan is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: java assignment

    thanks a million for the link managed to solve one problem... but still have the other... can you take a look at the code and the error i have just posted too please? .... much appreciated

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java assignment

    In order that your code can be easily read by others, we prefer it if you please post code as text in the forum and using

    [code]
    [/code]

    tags so that the code retains its formatting. The same with error messages. You're new here, and so it may take a couple of posts to get the hang of this forum's culture, but no biggie.

    As to your problem, you can't use private/public modifiers inside of a method. Just delete the term "private"

  7. #7
    drewjordan is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: java assignment

    sorry about that... you are right still have to get the hang of it...

    i have deleted 'private' and now it gave me the following error:

    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:9: error: constructor ScannedDocuments in class ScannedDocuments cannot be applied to given types;
    ScannedDocuments sc = new ScannedDocuments();
    ^
    required: int,String,String,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:10: error: package sc does not exist
    sc.set fbbnn;
    ^
    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:12: error: cannot find symbol
    System.out.println("Abstract: " + sc.getabstract());
    ^
    symbol: method getabstract()
    location: variable sc of type ScannedDocuments
    3 errors

    Tool completed with exit code 1

    is it posted properly like that? i just copied and pasted the error... thanks so much for your patience and kind assistance...

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java assignment

    Quote Originally Posted by drewjordan View Post
    sorry about that... you are right still have to get the hang of it...
    Again, no big deal -- you'll get the hang of things soon.

    i have deleted 'private' and now it gave me the following error:
    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:9: error: constructor ScannedDocuments in class ScannedDocuments cannot be applied to given types;
    ScannedDocuments sc = new ScannedDocuments();
    ^
    required: int,String,String,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    The error message tells you exactly what's wrong. You are calling the ScannedDocuments constructor without passing in any parameters, and it seems that the class expects an int and three Strings to be passed in. Since you have this class and we don't, you'll have to figure out how best to fix this.

    Java Code:
    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:10: error: package sc does not exist
            sc.set fbbnn;
              ^
    I can't see your code very clearly since it's still an image, but the line causing the error doesn't look right at all. Are you supposed to be calling a method there? what are you trying to do with this line since it isn't viable Java code?

    Java Code:
    C:\Documents and Settings\User\Desktop\STC\Assignments\Java\ACTUAL CODE\Tester.java:12: error: cannot find symbol
            System.out.println("Abstract: " + sc.getabstract());
                                                ^
      symbol:   method getabstract()
      location: variable sc of type ScannedDocuments
    Again, you have the code for the ScannedDocuments class, and it appears that there is no method called getabstract(). Are you spelling or capitalizing it wrong? Should it be getAbstract()? That's a big difference to the compiler.

  9. #9
    drewjordan is offline Member
    Join Date
    Jan 2012
    Posts
    5
    Rep Power
    0

    Default Re: java assignment

    thanks so much for today... i am trying to figure it out... but almost midnight here so i will head to bed soon and start afresh tomorrow... you will rpobably hear some more from me thanks... i really need some encouragement...

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java assignment

    Best of luck, and hang in there! Come on back if you need some help!

Similar Threads

  1. java assignment
    By omgonoes in forum New To Java
    Replies: 13
    Last Post: 04-23-2011, 03:29 AM
  2. Need Help with Java Assignment
    By smurf67 in forum New To Java
    Replies: 4
    Last Post: 03-26-2011, 11:25 AM
  3. Java assignment.
    By jmsjames in forum New To Java
    Replies: 14
    Last Post: 12-07-2010, 04:18 AM
  4. Help me please (Java assignment)
    By cris_carriaga in forum Java Applets
    Replies: 4
    Last Post: 10-06-2010, 05:11 PM
  5. Help with my assignment java
    By toby in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:59 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
  •