Results 1 to 2 of 2
- 10-11-2012, 01:41 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 2
- Rep Power
- 0
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{ try{ BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); while(input != null){ GraphAdjMatrix gAM = new GraphAdjMatrix(input); uGraphLists uG = new uGraphLists(gAM); System.out.print(uG); } input.close(); } catch(NumberFormatException e){ } }
Any help is greatly appreciated.
- 10-11-2012, 03:13 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 26
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.txtPlease do not ask for code as refusal often offends.
** This space for rent **
Similar Threads
-
Security alert doesn't accept user input?
By DLpres in forum New To JavaReplies: 4Last Post: 02-03-2012, 07:57 AM -
speech redirection from one app to other; changing input from mic to socket
By johnyjj2 in forum New To JavaReplies: 0Last Post: 12-12-2009, 12:29 AM -
Input redirection in Java
By freephoneid in forum Advanced JavaReplies: 6Last Post: 05-08-2009, 04:20 AM -
redirection
By prashant in forum NetworkingReplies: 1Last Post: 02-25-2009, 03:53 PM -
redirection in jsp
By valery in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-06-2007, 09:31 PM
Bookmarks