LancelotHolmes LancelotHolmes - 1 year ago 131
Java Question

powershell The '<' operator is reserved for future use in Java

I've read many answers about this question but nothing was found about the comparison between two files, actually this is a sample of the book Algorithms based on BinarySearch, here is the source code

import java.util.Arrays;
import edu.princeton.cs.algs4.*;

public class prac1_1_23{

public static boolean BinaryLookup(int key, int[] arr) {
int low = 0;
int high = arr.length - 1;
while(low <= high) {
int mid = low + ((high - low) >> 1);
if(key < arr[mid])
high = mid - 1;
else if(key > arr[mid])
low = mid + 1;
return true;
return false;

public static void main(String[] args) {
char symbol = '-';
int[] whitelist = new In(args[0]).readAllInts();
while(!StdIn.isEmpty()) {
int key = StdIn.readInt();
boolean found = BinaryLookup(key, whitelist);
if('+' == symbol && !found)
if('-' == symbol && found)

This sample utilizes a library made by the author of the book, which can be accessed via Algorithms, and the question is when I want to run this program via the PowerShell of windows,like the command

java prac1_1_23 largeW.txt < largeT.txt

I got a problem like

actually I find a solution to run this code but is useless to solve it on PowerShell which requires me to use the commandline program written by the author of this book which can be download on the website of "", and it need to compile and run the program with the commandline like

javac-algs4 //compile command

java-algs4 prac1_1_23 largeW.txt < largeT.txt //run command

it does work but I wonder if we can utilize the original CLI because I found someone can run the original code on the Linux operating system without problems.

Any help is appreciated, thank you.

Answer Source

This is a powershell issue as explained in The '<' operator is reserved for future use (PowerShell).

As explained in the first answer you can run your command like this;

Get-Content largeT.txt | java prac1_1_23 largeW.txt

Check out other answers for alternative ways to redirect input in powershell.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download