CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2010
    Posts
    161

    Problem: The java code does not compile

    Hello everyone
    I have this silly problem which I think can be solved easily but I cannot find the solution

    I am have two frames using eclipse,basically where I have all my code which when I run it opens a windows and do some calculation.

    I want to export it in order to hand in the work to my teacher so he can compile it then
    but he says that he can't compile my work
    so how do i export it in order to make it possible to see the source code and compile it for others?

    Thank you

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Problem: The java code does not compile

    The usual way of providing compilable code is to supply the .java source files in their package directories.

    If any additional library jars are used, you need to supply them too.

    To make things simple, the whole lot can be zipped up into a .zip file using WinZip or something similar. The recipient can unzip this to re-create the source package hierarchy and files. For example, if your source files are stored in packages under a project\src directory, you zip up the contents of the project\src directory, including subdirectories.

    The sole justification of teaching, of the school itself, is that the student comes out of it able to do something he could not do before. I say do and not know, because knowledge that doesn't lead to doing something new or doing something better is not knowledge at all...
    J. Barzun
    Last edited by dlorde; April 28th, 2010 at 10:17 AM.
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Jan 2010
    Posts
    161

    Re: Problem: The java code does not compile

    thank you for your reply
    well what i did basically was to copy and paste the whole folder containing projects/src and other folders and i copied it to the desktop to see if it works from a different path.
    well when i opened eclipse>then open file and went on the *.java file it has opened them perfectly showing the code and everything
    but when i run it it comes up with a windows saying ant build which i clicked on but nothing happens.

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Problem: The java code does not compile

    Presumably you need to create an Eclipse project for the code, or change the existing project details. I don't use Eclipse, so I wouldn't know... have you checked to see if there's an option to export the project?

    Have you asked your teacher exactly what he wants?

    Like I said before, the src directory tree & .java files, plus any extra jars should allow any competent person to compile the code. If your code uses other resources, like .properties files, icons, etc., you'll probably need to supply the resource directory as well, but the code should compile without them.

    The greatest obstacle to discovery is not ignorance, but the illusion of knowledge...
    D. Boorstin
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  5. #5
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Problem: The java code does not compile

    The problem is that Eclipse maintains all the build information for your project for you. This includes location of import files, dependencies, etc.

    The way you get this out for someone to build who is not using Eclipse is to export the build details as an Ant script. To do this, you need to do the following:

    • Click on File, then Export from the menu.
    • On the Export wizard that pops up, expand the General section, then select Ant Buldfiles
    • Click Next.
    • On the next pane, select the name of the project you want to create a build file for.
    • Leave "Check projects for Ant compatibility" checked.
    • Uncheck "Create target to compile using Eclipse compiler"
    • You can leave the build file name and JUnit output directory at their defaults.
    • Click on Finish
    .

    This should generate an Ant build.xml file that will contain targets for building your project. It will also have targets that match any Run Configurations you've created.

    You'll need to check the Ant build file to ensure there are no dependencies on files outside your build project directory included in the build. If there are, you'll need to include those files with your project. You can copy them to your project folder, then inside Eclipse change the dependency to the local copy. Then re-export your build file.

    If your instructor doesn't use Ant, then you'll need to translate the build process to some kind of script (batch file, shell script, etc.) for him/her to use to build the project.

    The best way to test this is to simulate what your instructor does. Load your files onto a different system and try to build them from the command line. Then see what happens.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured