Java – Submitting Java Code with JUnit Unit Test

eclipsejavajunit

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?

Best Answer

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.