Results 1 to 2 of 2
  1. #1
    static_rage is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default Program that must accept input redirection

    Hello all

    I've been using Java for a while now but this is the first instance I've had dealing with input redirection and I'm at point where I don't know what to do, I can't seem to find much information on how to achieve this and no tutors or lecturers are replying to my emails ( obviously they don't know either ). I have a program that should read in some input and then from that, construct an adjacency list for an undirected graph. I've got the program working to the point where if I run it, copy and paste the contents of a small .txt file and enter it, the desired output is shown. So the program works. However, I have to submit it into my university's auto marker which runs the file through a command line. The auto marker uses java graphs1 < test.txt as its input to the program. If I open up command prompt and attempt to do the same, I get the error message saying "Exception in thread "main" java.lang.NoClassDefFoundError: graphs1 (wrong name: A4/graphs1)."

    My program accepts input like so

    Java Code:
    public static void main(String[] args) throws IOException{
            BufferedReader input = new BufferedReader(new InputStreamReader(;
            while(input != null){
                GraphAdjMatrix gAM = new GraphAdjMatrix(input);
                uGraphLists uG = new uGraphLists(gAM);
            catch(NumberFormatException e){
    What should I be changing or doing differently to get the command line method to work? Any hints or tips?

    Any help is greatly appreciated.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Program that must accept input redirection

    Your graphs1 class is apparently in a package called A4, so you should either remove it from the package, or run it from the directory containing the A4 directory using:
    java A4.graphs1 < test.txt
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Security alert doesn't accept user input?
    By DLpres in forum New To Java
    Replies: 4
    Last Post: 02-03-2012, 07:57 AM
  2. Replies: 0
    Last Post: 12-12-2009, 12:29 AM
  3. Input redirection in Java
    By freephoneid in forum Advanced Java
    Replies: 6
    Last Post: 05-08-2009, 04:20 AM
  4. redirection
    By prashant in forum Networking
    Replies: 1
    Last Post: 02-25-2009, 03:53 PM
  5. redirection in jsp
    By valery in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-06-2007, 09:31 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