4

When invoking the 'java' process, I'm almost certain there is a way to have Java expand the contents of a file into a set of additional command-line arguments using the "@" symbol.

Something like:

java @myfile -cp foo -Dbar=baz com.mydomain.MyApp

And then the contents of "myfile" will be used as additional parameters.

It doesn't seem to work, but I'm certain that something very similar used to work. I've searched high and low but can't find anything on the InterNETs to help. Its driving me nuts! Someone please refresh my memory or lock me up.

2
  • What operating system are you using? This is easy to do in Unix. Commented Oct 29, 2009 at 23:02
  • For the record, this was added to the Java launcher (java/javaw) with Java SE 9. Prior to that release, only the compiler supported it. Commented Aug 27, 2020 at 16:07

6 Answers 6

11

It's probably the compiler you're thinking of:

javac [ options ] [ sourcefiles ] [ classes ] [ @argfiles ]

http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html

Sign up to request clarification or add additional context in comments.

1 Comment

Since Java 9, it is also supported on java.
1

I've never seen anything like that in any JVM I've used.

Are you sure it wasn't a specific Java application, e.g. Ant or something similar?

Comments

1

@ doesn't mean anything from the Java perspective. However in a DOS .BAT file it indicates that the files contained in the referenced file will be used.

e.g. DEL @FILENAME.TXT means that DOS will delete the files listed in FILENAME.TXT

I suspect that's what you're thinking of.

1 Comment

In what shell? Not XP's cmd one at least, and never saw in regular Dos either.
1

java VM takes options outlined in this document. I may be wrong but I never see anything what you described. So it could be something to do with shell you are using

Comments

0

Shell expansion is to what you're referring?

jvmargs=-Xmx786m -Dfoo=bar
java $jvmargs com.foo.Bar

.

set jvmargs=-Xms786m -Dfoo.bar
java %jvmargs% com.foo.Bar

Comments

-1

It is a quite common practice/convention, but I believe you have to implement it yourself (ie. get the filename, open it, read and parse it...).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.