anon
anon

Reputation:

Command in batch file to open up a .jar file

I created a registry that associates my .mike file with my notepad application I created.

I think that the issue lies somewhere in the registry since it can only run .exe files, although, I've heard that .batch and .exe files are one of the same thing.

I tried to open up a text file that I created using my application, and I received the message "[blank] is not a valid Win32 Application".

What is the command in the batch file to open up the file in the application, after double clicking on the file?

Upvotes: 0

Views: 1413

Answers (1)

Daniel Pryden
Daniel Pryden

Reputation: 60987

Based on your comments on your question, it looks like you just want to construct a command line to launch your JAR file. That's simple:

%JAVA_HOME%\bin\javaw.exe -jar C:\Path\To\YourApplication.jar

(Where %JAVA_HOME% refers to the directory where you installed Java.)

Sun's site has some comprehensive documentation on the java.exe and javaw.exe launchers. (That particular link is a bit dated, as it refers to Java 1.4.2, but the launching mechanism hasn't changed since then.)

If you want to launch your application and open a file, the command line is likely to be something like:

%JAVA_HOME%\bin\javaw.exe -jar C:\Path\To\YourApplication.jar C:\Path\To\SomeFile.txt

Then "C:\\Path\\To\\SomeFile.txt" will be passed to your main() method in its String[] args parameter.

Upvotes: 2

Related Questions