1

Let's assume I would like to execute a Java application:

java -cp j1:j2...:j9999 Main arg1 arg2

In this case, the java executable gets a plethora of arguments which, on certain OSes, can cause problems due to the length limitation of the command line string (see Maximum Length of Command Line String).

As a remedy, javac offers the @argfile (see here) which allows specifying the arguments within a file. The above example would look like this, if java supported it as well:

java @FileContainingArguments.txt

and the content of FileContainingArguments.txt is:

-cp j1:j2...:j9999
Main
arg1
arg2

So the question is, why java doesn't support it, while javac and javadoc do?

Community
  • 1
  • 1
Zoltán Haindrich
  • 1,788
  • 11
  • 20
  • If you're asking how to pass parameters to a compiled Java program, you don't need the `@` decorator and can pass them in by name: `java MyProgram data_file.txt`. If they're in a different folder, you can pass them in by path. – wadda_wadda Oct 28 '15 at 12:18
  • @wadda_wadda not really, i want to pass a very large `classpath` – Zoltán Haindrich Oct 28 '15 at 12:23
  • 1
    There are libraries for dealing with command line options: apache **CLI** and **args4j**. You could contribute code for such a @-file inlining to them. I am not aware of any of them having that. – Joop Eggen Oct 28 '15 at 12:24
  • 1
    A classpath can be specified in a jar's META-INF/MANIFEST.MF as `Class-Path: ...` and you may use directories of jars in the class path. – Joop Eggen Oct 28 '15 at 12:25
  • You question is too broad. If you want to pass huge classpath please ask about this specific problem – talex Oct 28 '15 at 12:39
  • Please, think carefully about what you really want to know. Do you really want to know **why** that feature isn’t supported or do you want to know **whether** it is support or a workaround exists? If you find out that your written question doesn’t match your actual intentions, edit your question appropriately. – Holger Oct 28 '15 at 14:24

1 Answers1

1

I don't know why it is not supported yet, but it seems Open JDK 9 will support it, once it is released: https://bugs.openjdk.java.net/browse/JDK-8027634. I am not sure about Oracle.

Katona
  • 4,816
  • 23
  • 27