- VSCode Version: 1.41.1
- OS Version: Windows 10
Steps to Reproduce:
- Use launch.json to pass an input file to main via args[] and consume the input
- Try to do it from command line
Does this issue occur when all extensions are disabled?: No
I love the IDE and launch.json. Thank you for your work. I am trying to pass an input file to the main() via "<" which is something I have done a million times before. But the script that parses Launch.json swallows the "<", so the workaround I found on the issues for launch.json git was to escape it like so: "<", which I did and my program runs fine. But when I submit it, my program throws the following exception java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length because they do : % java Permutation 3 < distinct.txt Here are the relevant parts of my program:
public static void main ( String [] args ) { //StdOut.println("Getting Here."); int k = Integer.parseInt(args[0]); RandomizedQueue<String> r = new RandomizedQueue<>(); int counter = 0; outerloop: while (!StdIn.isEmpty()) { StdOut.println("Getting Here."); counter++; String s = StdIn.readString(); } } }
when I use the "<" from the Integrated Terminal, I do not see my printout of "Getting Here". Here is what I mean:
c:\Users\usr\source\assignment2>cd c:\Users\usr\source\assignment2 && C:\Users\usr\.vscode\extensions\vscjava.vscode-java-debug-0.24.0\scripts\launcher.bat "C:\Program Files\Java\jdk1.8.0_231\bin\java" -Dfile.encoding=UTF-8 -cp C:\Users\usr\AppData\Local\Temp\cp_en9b6ty2p1y9jb8dn65bawzty.jar assignments.Permutation 3 < C:/Users/usr/source/assignment2/assignment2/target/classes/input.txt
But when I use the debug pulldown with the following config, the program runs fine, and produces the output I want:
{ "type": "java", "name": "Permutation<assignment2> Input 1", "request": "launch", "mainClass": "assignments.Permutation", "projectName": "assignment2", "args": "3 C:/Users/usr/source/assignment2/assignment2/target/classes/input.txt" }, { "type": "java", "name": "Permutation<assignment2> Input 2", "request": "launch", "mainClass": "assignments.Permutation", "projectName": "assignment2", "args": "4 C:/Users/usr/source/assignment2/assignment2/target/input2.txt" },
I am glad to share anything else you may need. Oh, I can also run the program fine, when I modify the launch.json config to:
{
"type": "java",
"name": "Permutation Input 1",
"request": "launch",
"mainClass": "assignments.Permutation",
"projectName": "assignment2",
"args": "3 < C:/Users/usr/source/assignment2/assignment2/target/classes/input.txt"
},
{
"type": "java",
"name": "Permutation Input 2",
"request": "launch",
"mainClass": "assignments.Permutation",
"projectName": "assignment2",
"args": "4 < C:/Users/usr/source/assignment2/assignment2/target/input2.txt"
},
I need you to tell me if the integrated terminal commands are somehow parsed with vscode script, and how I can bypass that. I going to try to use the Windows command like and other terminal emulators. But I wanted to get your advice on this also, since there is a discrepancy between how the IDE treats standard input vs. vanilla java.
Steps to Reproduce:
Does this issue occur when all extensions are disabled?: No
I love the IDE and launch.json. Thank you for your work. I am trying to pass an input file to the main() via "<" which is something I have done a million times before. But the script that parses Launch.json swallows the "<", so the workaround I found on the issues for launch.json git was to escape it like so: "<", which I did and my program runs fine. But when I submit it, my program throws the following exception
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for lengthbecause they do :% java Permutation 3 < distinct.txtHere are the relevant parts of my program:public static void main ( String [] args ) { //StdOut.println("Getting Here."); int k = Integer.parseInt(args[0]); RandomizedQueue<String> r = new RandomizedQueue<>(); int counter = 0; outerloop: while (!StdIn.isEmpty()) { StdOut.println("Getting Here."); counter++; String s = StdIn.readString(); } } }when I use the "<" from the Integrated Terminal, I do not see my printout of "Getting Here". Here is what I mean:
c:\Users\usr\source\assignment2>cd c:\Users\usr\source\assignment2 && C:\Users\usr\.vscode\extensions\vscjava.vscode-java-debug-0.24.0\scripts\launcher.bat "C:\Program Files\Java\jdk1.8.0_231\bin\java" -Dfile.encoding=UTF-8 -cp C:\Users\usr\AppData\Local\Temp\cp_en9b6ty2p1y9jb8dn65bawzty.jar assignments.Permutation 3 < C:/Users/usr/source/assignment2/assignment2/target/classes/input.txtBut when I use the debug pulldown with the following config, the program runs fine, and produces the output I want:
{ "type": "java", "name": "Permutation<assignment2> Input 1", "request": "launch", "mainClass": "assignments.Permutation", "projectName": "assignment2", "args": "3 C:/Users/usr/source/assignment2/assignment2/target/classes/input.txt" }, { "type": "java", "name": "Permutation<assignment2> Input 2", "request": "launch", "mainClass": "assignments.Permutation", "projectName": "assignment2", "args": "4 C:/Users/usr/source/assignment2/assignment2/target/input2.txt" },I am glad to share anything else you may need. Oh, I can also run the program fine, when I modify the launch.json config to:
{
"type": "java",
"name": "Permutation Input 1",
"request": "launch",
"mainClass": "assignments.Permutation",
"projectName": "assignment2",
"args": "3 < C:/Users/usr/source/assignment2/assignment2/target/classes/input.txt"
},
{
"type": "java",
"name": "Permutation Input 2",
"request": "launch",
"mainClass": "assignments.Permutation",
"projectName": "assignment2",
"args": "4 < C:/Users/usr/source/assignment2/assignment2/target/input2.txt"
},
I need you to tell me if the integrated terminal commands are somehow parsed with vscode script, and how I can bypass that. I going to try to use the Windows command like and other terminal emulators. But I wanted to get your advice on this also, since there is a discrepancy between how the IDE treats standard input vs. vanilla java.