Allen Huskins Allen Huskins - 1 year ago 57
Java Question

creating my own file type and making it run another file?

I'm currently writing my own programming language for my senior project and using java to compile it. (in a sense where it reads through a text file and pulls out keywords and phrases and acts on them how i define). i would like to be able to have my text file be of type ".SeniorProject" for example, and then double click it and then it direct to the actual java program that reads it and acts upon on, also i would like if it would take and give input/output through command prompt instead of eclipse which i'm currently using. could someone direct me to a guide to set this up or explain it if possible. i will be using a windows device for this, not linux so i know that makes it more complicated for me wanting to give and receive input from the command prompt.

Answer Source

First of all, to run the program outside of eclipe, you can compile it into a .jar file (Java executable). In eclipse, you can do this by going to file -> export -> JAR file. Afterwards, you can simply type java <yourfilename>.jar in the command prompt and use the program like this.

Associating the file extension with your jar is a little bit trickier, in theory you can associate any file extension to any executable, but only windows executables. You could maybe create a .bat file that simply starts your jar on the jvm or use an exe wrapper like Launch4j to create an exe form your jar file.

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