0

I wanted to put a java classfile up for download recently, which people could run in Terminal. It's a Minecraft command generator, so the people downloading it won't necessarily have the greatest mental capacity (I'm referring to 8-year-olds who have no idea what they're doing, of course).

Anyway, I wanted to provide a simple, single command, both for the Mac / Linux terminal and the Windows command line, that ran the classfile without any complications. The problem is, I don't want to execute it by doing /cd path, and then doing java someFolder.someClass. I just want to have a single command to open the file. If anyone could provide these commands for me, both in Mac / Linux and Windows, that would be great.

Sorry for the super long explanation :P

Bubletan
  • 3,833
  • 6
  • 25
  • 33
Dan95363
  • 11
  • 3
  • you can write a script in sh and cmd versions and make it executable like run.sh and run.cmd, a lot of standalone java applications work like this – davidluckystar Apr 17 '15 at 19:05

2 Answers2

1

A jar file with a main class in the manifest would probably be the easiest thing. Then the command is java -jar myjarfile.jar.

A swing application would probably be easier as the default way of running executable jars doesn't open a command prompt (it uses javaw instead of java).

Unihedron
  • 10,902
  • 13
  • 62
  • 72
brain
  • 5,496
  • 1
  • 26
  • 29
0

You will have to first start a terminal and then run java in that terminal, which can be a bit tricky.

How to open a command terminal in Linux?

Why not create an interface (Swing) and pack everything in a jar?

Community
  • 1
  • 1
Slow Trout
  • 492
  • 3
  • 13