Results 1 to 11 of 11
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: compile my program

  1. #1
    suriyababu is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default compile my program

    hi Patterc,

    i have creating the java program for convert the text from editable/non-editable pdf.

    i have received 2 errors while compile the program. plz find my below code for your review, clear the code error.

    Code:

    package com.gnostice.pdfone.PDFOne;
    package com.gnostice.pdfone.PdfDocument;
    package com.gnostice.pdfone.PdfException;

    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;


    public class TextExport {

    public static void main(String[] args) throws IOException, PdfException, Exception {

    int i, n;

    // Create a file writer instance
    FileOutputStream fos = new FileOutputStream("Output_Docs\\extracted_text.doc" );
    OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");

    // Load a PDF document
    PdfDocument doc = new PdfDocument();
    doc.load("Input_Docs\\sample_doc.pdf");

    // Extract text from page 1 of the document
    // and save it to the file writer
    doc.saveAsText(1, osw);
    osw.close();

    // Close the PDF document
    doc.close();

    }
    }


    Thanks,
    Suriyababu.SS

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

    Default Re: compile my program

    Please use [code] tags [/code] when posting code so it retains its formatting.
    If you are getting errors then post the full error text here and highlight the lines on which they occur.
    Please do not ask for code as refusal often offends.

  3. #3
    suriyababu is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: compile my program

    Dear Tolls,

    Thanks for the quick reply. here after i have following as per your instruction.

    could you clear my doubt,

    *Code*

    package com.gnostice.pdfone.PDFOne;
    package com.gnostice.pdfone.PdfDocument;
    package com.gnostice.pdfone.PdfException;

    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;


    public class TextExport {

    public static void main(String[] args) throws IOException, PdfException, Exception {

    int i, n;

    // Create a file writer instance
    FileOutputStream fos = new FileOutputStream("Output_Docs\\extracted_text.doc" );
    OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");

    // Load a PDF document
    PdfDocument doc = new PdfDocument();
    doc.load("Input_Docs\\sample_doc.pdf");

    // Extract text from page 1 of the document
    // and save it to the file writer
    doc.saveAsText(1, osw);
    osw.close();

    // Close the PDF document
    doc.close();

    }
    }

    */code*

    *Error*

    $javac /tmp/135952418214353/com/gnostice/pdfone/PdfException/TextExport.java 2>&1
    /tmp/135952418214353/com/gnostice/pdfone/PdfException/TextExport.java:2: class, interface, or enum expected
    package com.gnostice.pdfone.PdfDocument;
    ^
    /tmp/135952418214353/com/gnostice/pdfone/PdfException/TextExport.java:3: class, interface, or enum expected
    package com.gnostice.pdfone.PdfException;
    ^
    2 errors

    */Error*

    Thanks,
    Suriyababu.SS

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

    Default Re: compile my program

    You missed the '[' and ']' around code and /code.

    You are only allowed one package declaration for a class file.
    After all a class can only be in one package.
    Please do not ask for code as refusal often offends.

  5. #5
    suriyababu is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: compile my program

    hi Team,

    Any reply for above my request.

    Thanks & Regards,
    Suriyababu.S.S

  6. #6
    SurfMan's Avatar
    SurfMan is online now Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    753
    Rep Power
    2

    Default Re: compile my program

    Quote Originally Posted by Tolls View Post
    You missed the '[' and ']' around code and /code.

    You are only allowed one package declaration for a class file.
    After all a class can only be in one package.
    I think he accidently typed "package" instead of "import". The keys are like, right next to each other after all ;)

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

    Default Re: compile my program

    Quote Originally Posted by suriyababu View Post
    hi Team,

    Any reply for above my request.

    Thanks & Regards,
    Suriyababu.S.S
    What did you not understand about my reply.

    You can only have one 'package' statement at the top of a class file.
    This assumes (thanks to SurfMan) that those are not, in fact, supposed to be 'import' statements.
    Please do not ask for code as refusal often offends.

  8. #8
    suriyababu is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: compile my program

    Hi Tools,

    am new for Java Program. could you plz give the corrective code for above program.

    Thanks,
    Surya

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

    Default Re: compile my program

    Quote Originally Posted by suriyababu View Post
    am new for Java Program. could you plz give the corrective code for above program.
    No, because this is a forum and not a code factory. But here are a couple of resources where you can learn stuff:
    The Java™ Tutorials
    The Java™ Language Specification

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

  10. #10
    suriyababu is offline Member
    Join Date
    Jun 2012
    Posts
    6
    Rep Power
    0

    Default Re: compile my program

    Hi DarrylBurke,

    Thanks for the solution. Also, i have received three errors after using only one package(package com.gnostice.pdfone). could you clarify the error.

    Error

    $javac /tmp/135960190117357/com/gnostice/pdfone/PDFOne/TextExport.java 2>&1
    /tmp/135960190117357/com/gnostice/pdfone/PDFOne/TextExport.java:10: cannot find symbol
    symbol : class PdfException
    location: class com.gnostice.pdfone.PDFOne.TextExport
    public static void main(String[] args) throws IOException, PdfException, Exception {
    ^
    /tmp/135960190117357/com/gnostice/pdfone/PDFOne/TextExport.java:19: cannot find symbol
    symbol : class PdfDocument
    location: class com.gnostice.pdfone.PDFOne.TextExport
    PdfDocument doc = new PdfDocument();
    ^
    /tmp/135960190117357/com/gnostice/pdfone/PDFOne/TextExport.java:19: cannot find symbol
    symbol : class PdfDocument
    location: class com.gnostice.pdfone.PDFOne.TextExport
    PdfDocument doc = new PdfDocument();
    ^
    3 errors

    /Error

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

    Default Re: compile my program

    Well, where are those classes?
    Since they don't seem to be in the com.gnostice.pdfone.PDFOne package, then you need to import them.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. i can compile but not run the program???
    By stefandanielsen in forum New To Java
    Replies: 4
    Last Post: 03-10-2011, 12:15 PM
  2. Program will not compile?
    By vtecjerry in forum New To Java
    Replies: 1
    Last Post: 09-29-2010, 10:20 PM
  3. my program cannot be compile
    By justlynn in forum NetBeans
    Replies: 8
    Last Post: 08-17-2010, 10:11 AM
  4. Program Won't Compile
    By JavaLovenJoe in forum New To Java
    Replies: 2
    Last Post: 04-22-2008, 01:31 PM
  5. Compile a program
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 09:09 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
  •