How do I Run a .jar file as an exectuable under Win 7 Home Pro?

Xploding Bill

New member
As the title says. I just recently had to rebuild my system from the ground up and since XP can no longer be registered, I bit the bullet and upgraded to Win & home pro. Only major problem is that now I can;t figure out how to make a .jar file run as a stand alone program. Under XP, I just went into the files options and changed it to run as an executable but under Win 7, I can't even FIND that option!

Any and all help would be greatly appreciated! I'm using v14.5 at the moment but I'd really like to go back to doing my daily updates from the jar files.

Thanks in advance, Xploding Bill.
 
First, download and install Java.
That alone should fix the issue, if not, then right click the Jar, Open with->Choose default program...
Navigate to Java (most likely in Program Files) jre6/bin/ and choose javaw.exe.

Make sure "Always use the selected program to open this type of file" is checked and voila.
 

Xploding Bill

New member
Thanks, I finally figured that out but now I get the following error:

Could not find the main class: D:\kol mafia\kolmafia-9276.jar.
Program will exit.

So now I'm REALLY stumped!
 

fronobulax

Developer
Staff member
There are alternatives that do not require jsmooth if you are interested. I use a batch file, for example, but that is just because associating the jar file with Java and double clicking it ends up using "the wrong" locations for files and directories.
 

xKiv

Active member
The problem is that you are running "javaw KolMafia-####.jar", where you should be running "javaw -jar KolMafia-####.jar".
You can't set this up vie the "standard" file associating mechanism.
Total commander shows that on my system, jar files are actually associated with "executable jar file ("C:\Program Files\Java\jre6\bin\javaw.exe" -jar "%1" %*)" and that works.

Apparently, microsoft no longer allows us to do that from the GUI, but the terminal (cmd) commands still exist:

Code:
ftype jarfile="C:\Program Files\Java\jre6\bin\javaw.exe" -jar "%1" %*
assoc .jar=jarfile

ETA: the "-jar" part is *important*. It tells java the next parameter is a filename. Without it, it thiks you are trying to runthe *class* KolMafia-####.jar, which would exist in a file named KolMafia-####\jar.class (that's a directory and the file is in it!) in the current directory (or anywhere on your CLASSPATH, but that's not important). That file obviously doesn't exist.
 
Last edited:

Theraze

Active member
For Windows 7 you might want to replace "Program Files" with "Program Files (x86)".

That depends completely on if you're running 32 or 64 bit Win7, as well as which version of Java you've installed.

1) Windows 7 32-bit: Only possibility is Program Files.
2) Windows 7 64-bit: Varies (2 of the 3 possibilities allow for Program Files folder, 2 of the 3 possibilities allow for Program Files (x86) folder)
2a) Only 32-bit Java installed - Program Files (x86) only
2b) Only 64-bit Java installed - Program Files only
2c) Both installed - Program Files and Program Files (x86) both work

As I've hopefully shown, Program Files is always a valid location... if you've installed 64-bit Java and have 64-bit Windows, Java will be in the PF folder. If you have 32-bit Windows, it will be in the PF folder. Only if you have only 32-bit Java and 64-bit Windows, and the above doesn't work... you can always install 64-bit Java and make it work.
 

Xploding Bill

New member
Okay, I've tried all the suggestions in this thread with no useful result that isn't negative so far. When I try the ftype commands I get access denied even though I'm most definitely in Administrator mode. Also, even though the svn site says that there's a new .exe built every Sunday at midnight, the one up there is 14.7 r9640 - will you guys post a new one soon?

Thanks!

edited to add: if someone would be kind enough to point me towards a place where I can grab a newer .exe version, I'd be grateful!
 

Theraze

Active member
Try these commands in your command line:
dir "C:\Program Files\Java\jre6\bin\javaw.exe"
dir "C:\Program Files (x86)\Java\jre6\bin\javaw.exe"
What returns a file? It might be both, or neither, or just one...
 
When I try the ftype commands I get access denied even though I'm most definitely in Administrator mode.

Well of course, why would administrators have administrator priveleges? That's just silly.

Try typing "cmd" into your start menu's search field; instead of opening in though, right click and select Run as administrator.
This should allow you to ftype and assoc to your hearts desire, even if it is redundant and stupid on Microsoft's part.
 

fronobulax

Developer
Staff member
Since the ftype commands have to be typed into a command window and it is quite possible to run a command window as a non-administrator, you might consider making absolutely sure the command window was started as an administrator. Easiest way would be to log into the administrator account and the run things. Alternatively, navigate to the command prompt shortcut and try Run as Administrator.

For the record jar files have always worked for me on Windows 7 so this is almost certainly a problem with your system and not mafia. An alternative way of solving your problem might be to find a non-KoLmadia jar file and see if you can run it. But first, why don't you make certain the command window is running as an administrator and try the ftype commands?
 

Xploding Bill

New member
I've tried running the ftype commands under the admin account and since I've been building systems since you had to solder the motherboard together, I feel just a tad bit stupid here. Could someone just point me to an already compiled version that's newer than whats on the svn page? Hell, I'd be happy if someone would just EMAIL me the damn thing at this point.

FWIW, I have no problems with jar files, i.e., opening and closing them and whatnot, it's just getting them to run by clicking on them that seems to have me stumped. What really pisses me off is that I never had a problem running them under XP Pro SP3. Hell, point me to a program that will let me compile the damn thing myself and I'll even try that. Preferably a ingle, all-in-one program if such a thing even exists as I really don't feel like learning a bunch of new progs just for one thing no matter HOW awesome mafia is!

Also, also, thanks for all the responses. You guys (and gals, I assume) are what makes this type of sommunity thrive.
 

fronobulax

Developer
Staff member
I see your soldering motherboards and raise you with BASIC on a General Electric mainframe in 1968 ;-)

First, on my system, I keep the jar file in the root of a directory that has the scripts, sessions, data and other mafia required subdirectories. When I right click on a jar file and look at properties it says it is an Executable Jar File and opens with Java (TM) Platform SE binary. That may be because I have the SDK installed on my system, but it might be worth a shot - installing the SDK.

One workaround might be a batch file with the line "java -jar KoLmafia.jar".

It wouldn't generate the missing main class message but keep in mind that KoLmafia does not work with Java 1.7 which is the latest/newest.

I'll see if I can figure out anything else for you.
 
I've tried running the ftype commands under the admin account and since I've been building systems since you had to solder the motherboard together, I feel just a tad bit stupid here.
I'd just like to re-iterate that -being- an admin isn't enough... you must also go into cmd via "Run as admin".
Could someone just point me to an already compiled version that's newer than whats on the svn page? Hell, I'd be happy if someone would just EMAIL me the damn thing at this point.

FWIW, I have no problems with jar files, i.e., opening and closing them and whatnot, it's just getting them to run by clicking on them that seems to have me stumped. What really pisses me off is that I never had a problem running them under XP Pro SP3. Hell, point me to a program that will let me compile the damn thing myself and I'll even try that. Preferably a ingle, all-in-one program if such a thing even exists as I really don't feel like learning a bunch of new progs just for one thing no matter HOW awesome mafia is!

Also, also, thanks for all the responses. You guys (and gals, I assume) are what makes this type of sommunity thrive.

jsmooth takes .jars and turns them into (currently, only x86) .exes.

I -think- this comes with the mafia source on checkout... but I could be wrong. It's a little complex, some of the options are misleading, but I -know- the mafia source comes with a jsmooth config file ready to go.
Or, pm me your email address and I'd be happy to email you the exe.
 

Xploding Bill

New member
I see your soldering motherboards and raise you with BASIC on a General Electric mainframe in 1968 ;-)

First, on my system, I keep the jar file in the root of a directory that has the scripts, sessions, data and other mafia required subdirectories. When I right click on a jar file and look at properties it says it is an Executable Jar File and opens with Java (TM) Platform SE binary. That may be because I have the SDK installed on my system, but it might be worth a shot - installing the SDK.

One workaround might be a batch file with the line "java -jar KoLmafia.jar".

It wouldn't generate the missing main class message but keep in mind that KoLmafia does not work with Java 1.7 which is the latest/newest.

I'll see if I can figure out anything else for you.

When I look at the properties, it just says JAR file - nothing about it being executable - it does say that it opens with java though. I'll dink around with batch files and see what happens.

Also, yes, you most DEFINITELY win the epeen contest when it comes to being around computers! I was 7 in 1968 although I did teach myself minimal BASIC on a TI 99/4A which has to be some kind of achievement. I deserve a trophy dammit!
 

Xploding Bill

New member
I'd just like to re-iterate that -being- an admin isn't enough... you must also go into cmd via "Run as admin".


jsmooth takes .jars and turns them into (currently, only x86) .exes.

I -think- this comes with the mafia source on checkout... but I could be wrong. It's a little complex, some of the options are misleading, but I -know- the mafia source comes with a jsmooth config file ready to go.
Or, pm me your email address and I'd be happy to email you the exe.

email has been peemed and thanks muchly!
 
Top