1

I made a little minesweeper game and I want to send it to a friend so he can test it out. The problem(probably) is that he isn't able to run it because he doesn't have Java for programmers(JDK) installed on his computer. How is it possible to export a program that will work on other computers without having to download any other files**(other than JRE)**?

EDIT: I did read about converting the JAR to EXE but I couldn't find anything that would do it.

EDIT2: Download here the JAR file(it's only supposed to open a blank window). I tested it on two computers with JDK installed and it worked, whilst on two others without JDK(one with the newest JRE) it couldn't start. This is the error: picture .

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Jan Burak
  • 25
  • 1
  • 7
  • Does your friend have the JRE (Java Runtime Environment) installed? (This is installed by default on many operating systems, but not all.) – Greg Hewgill Jan 22 '12 at 20:51
  • I'm asking him right now, but I'd like to know how to make a standalone game in Java that is generally compatible with other PCs, like for example Minecraft(my friend can run Minecraft on his computer). – Jan Burak Jan 22 '12 at 20:58
  • @JanBurak: Even Minecraft requires JRE to be installed separately, see here: http://www.minecraftwiki.net/wiki/Hardware_performance -> "Java Runtime Environment (JRE) 6 and up is required to be able to run the game." – esaj Jan 22 '12 at 21:14

6 Answers6

2

There is no way to "not have to download any other files" - your friend must minimally have some Java Runtime Environment (or just "Java") installed in order to run Java programs.

If your friend has Java installed, you can package your application as a fat JAR so that he only needs your JAR to run your application (depending on the application - but I think yours should be fine).

Community
  • 1
  • 1
cheeken
  • 33,663
  • 4
  • 35
  • 42
  • I did exactly as it says in that topic and when I try to open the JAR,I get an error "A Java Exception has occurred" and it doesn't open. I have the latest JRE installed and the program works fine whilst running it in eclipse. When I select the main class whilst exporting the JAR, there's no error and the program doesn't start at all. – Jan Burak Jan 22 '12 at 21:20
  • @JanBurak Try running the `jar` from the command line via `java -jar MyJar.jar` and see what the console tells you. (It sounds like you're double-clicking it, which generates less useful error messages.) – cheeken Jan 22 '12 at 21:26
  • I picked a wrong option about error handling so Eclipse did something about "unused" variables that were actually used by the program and it couldn't start(or some other compile errors). The JAR works on my computer now, but I still have to check if it works on others. Probably I'll be able to check that tomorrow as my friend is offline. – Jan Burak Jan 22 '12 at 21:33
  • @JanBurak Neat. If it runs on your JRE, it's extremely likely it will run on others. Hope it works out. – cheeken Jan 22 '12 at 21:36
  • When he tries to run it by double clicking he gets an error "could not find the main class : game.gameManager". He's now trying to run it through cmd. – Jan Burak Jan 22 '12 at 21:55
  • @JanBurak That means you compiled your application with a newer version of Java than your buddy has. He'll need to update his JRE to at least whatever you compiled with. – cheeken Jan 22 '12 at 22:11
  • He downloaded the newest JRE(version 6 update 30, same as mine) and the error is exactly the same. – Jan Burak Jan 22 '12 at 22:23
  • The newest JRE is version 7, not 6. Please check your Eclipse project to see what JDK level is being used - it sounds like it must be 7. – cheeken Jan 22 '12 at 23:12
  • Oh, I see. I've just read that Java 7 is developers only so Java 6 was the default one to download. I'll look into it tomorrow then. Thank you for your help, cheeken! – Jan Burak Jan 22 '12 at 23:53
2

There are tools available, google "java windows executable" and you will find e.g.

Or already on SO

Community
  • 1
  • 1
stacker
  • 68,052
  • 28
  • 140
  • 210
1

Java Web Start is ideal for this, as it can enable the user to install required components on supported platforms. There's a simple example here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Not possible, a JRE (Java Runtime Environment) is the least that must be present. If that is you can just export your program as jar specifying the main class in its manifest. Your friend should if a JRE is installed be able to run the jar file directly.

stryba
  • 1,979
  • 13
  • 19
0

You could send your friend the compiled binary of your game. In that scenario, your friend will only need to have the Java Runtime Environment installed in order to play your game.

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
0

Make executable JAR from it, your friend will still need JRE.

Rostislav Matl
  • 4,294
  • 4
  • 29
  • 53