Results 1 to 5 of 5
  1. #1
    JMaste is offline Member
    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Question Complex file input

    Hi,

    Overview: I am creating automated assignment marking system, in which the goal is: suppose there are 100 students' assignment.java in a directory and if I start my program it should check all of the assignment.java one by one and generate a report based on that.

    Right now, I import one java file in my project and test that and after finishing that I import another assignment.java and test that, but I am not able to figure out how would I automate the system so, it automatically replaces each assignment.java(in specified path) after finishing marking that.

    Any help would be greatly appreciated.:)

    Thank you.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    how about some kind of classloader or shell script stub invoke a java vm where it sets the classpath to your stub that runs the assignment.java and the specific assignment.java

    for example if there is a users/user1/assignment.java we could compile this to the same folder users/user1/assignment.class

    perhaps then we could use reflection to load the assignment.class file, or if they are all called assignment then just constructing the classpath to be users/user1:./myfolder

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Right now, I import one java file in my project and test that

    You might want to consider compiling from within your testing program (like this java2s.com example). That way actually compiling can be part of your test and compiler messages can be part of the report you generate.

    The actual tests you do would replace the "Hello world" output generated in the java2s example linked to above. I presume you have some way of knowing (based on the source file name?) what tests you are going to do. Again failing to declare the right method to allow the test to be run will be caught and can be reported on along with any other test sucess or failure.

    I don't know whether compiling classes with the same name as ones already compiled causes a problem (my guess is that it would). And have no clue how you would deal with that, never having used class loaders.

  4. #4
    JMaste is offline Member
    Join Date
    Jul 2010
    Posts
    5
    Rep Power
    0

    Question More clear explanation

    Thanks a lot for replies. But looks like I want to do something different :(

    Clearer explanation of the question:
    At the moment, I have got assignment.java of 1 student and my Testing.java (which creates an object of the class in assignment.java and generates a report based on the output of assignment.java). So, till now what I am able to achieve is: Inside the Test project (which contains Testing.java), I import assignment.java; run the Testing.java and generate the report. When it comes to second student, I remove previous assignment.java import new assignment2.java(second student); run the Testing.java, which uses the students program and generates the report.

    What I want to achieve is, In my Testing.java instead of importing assignments one by one and marking them, I want to automate it. i.e. In my Testing.java, if I specify the path of the directory in which all assignments are placed, my system should automatically overwrite (import new assignment removing the older) assignment.java and generate a report based on that. :confused:

    Thanks a lot.

  5. #5
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    yes, kind of like compiling from within your program

    *for each file of *.java name in the input assignments folder.
    * remove all contents of a work/ folder
    * copy the file as work/assignment.java - would require text search replace of the class name in the file, if the file was called assignment2.java and inside the file there was public class assignment2 {... we would need to have this renamed to be just assignment.
    * javac compile the file work/assignment.java to work/assignment.class
    * invoke Testing.java, which includes work/ as the classpath, Testing.java has import assignment.java

    ?

Similar Threads

  1. Replies: 7
    Last Post: 10-12-2010, 08:34 AM
  2. Replies: 8
    Last Post: 05-12-2010, 07:19 PM
  3. count character in text file as input file
    By aNNuur in forum New To Java
    Replies: 7
    Last Post: 03-25-2010, 04:01 PM
  4. retain value of input type file in a jsp file while being dynamically generated
    By nidhi c in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:21 AM
  5. Complex proximity Clauses
    By peiceonly in forum Lucene
    Replies: 1
    Last Post: 08-07-2007, 05:43 PM

Posting Permissions

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