Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have mostly worked on simple java programs and compiled and run them with Eclipse on Windows. So, I have no experience of using command prompt for compiling Java projects and do not have much info about what actually happens beneath the play button in Eclipse.

Now I have to submit a Java application which will have basic operation on XML. My project also will have (JUnit) Unit Test.

My question is related to submission of this Project.

  1. Which files would be necessary to submit the code. So, it executes properly?
  2. Does choosing Eclipse as an IDE or junit as a unit testing framweork produces any dependenices i.e the executor of the program should have eclipse/libraries to execute the program on his machine?
share|improve this question
    
Where are you submitting your project to? –  Bernard Apr 15 '12 at 17:26
    
@Bernard : Meaning ?? –  LivingThing Apr 16 '12 at 10:47
    
"Which files would be necessary to submit the code." Where are you submitting the code to? You weren't specific on this. Is it part of an open source project? Going directly to a customer? –  Bernard Apr 16 '12 at 13:40
    
It had to be directly submitted to the customer. But would it matter if this would have been a open source project.. –  LivingThing Apr 17 '12 at 5:57
    
In that case, I wouldn't include your unit tests unless the customer specifically asks for them. –  Bernard Apr 17 '12 at 13:21

2 Answers 2

up vote 3 down vote accepted

If your application is doing XML operations and has JUnit tests then the only real dependency there is the dependency to junit.jar. Your application should not need any Eclipse specific libraries on the classpath.

You sound as if you do not have a complete understanding of what the classpath is and how it relates to the compilation and execution of Java code. I highly recommend that you learn how to develop a simple application with a text editor and the command line.

As far as submitting your code, you can compile and package your code into a JAR file, and submit this along with junit.jar and a simple batch file or shell script that will execute the Java virtual machine to run your program.

Another way would be to compile your program, unpackage junit.jar, and package it all together into an Executable Jar file. All of your classpath dependencies will be self contained within the one file and on most operating systems it can be launched as a typical executable.

share|improve this answer

You can easily use the eclipse "file->export->java->jar" function to create a compiled package of your code. You can select various options depending on your whishes, e.g. exporting the source with it. If you select "runnable jar file" you can easily select a run configuration which Eclipse will "embed" into the .jar file.

Using an IDE should not add dependencies to your code. Using a unit testing framework does of course add the testing framework as a dependency for running the tests (but does not add them as a dependency for your main code)

You might also want to look at Maven, which can automate dependency managment and the creation of output (Maven calles them target) files.

share|improve this answer
2  
+1 for maven; IMO one of the only sane ways in the Java ecosystem to manage dependencies –  Joseph Weissman Apr 10 '12 at 15:10
1  
One of my biggest problems with Maven is that it shelters application complexities like dependency management from developers like the OP to where they still do not understand the basic fundamentals of the classpath. That and I am a control freak with my dependent libraries and like gathering the specific versions of everything into one place that I control. There is still a sizable Anti-Maven community in Java. –  maple_shaft Apr 10 '12 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.