2

[1 file extension (.atb) and one jar file picture

Here is a picture of the 2 files in question, one .atb and one .jar

If i just click the jar file, it opens my program smoothly, no questions asked. If i click the New Text Document and choose "y" as my default program, it says this:

picture of message

If i do all this with .txt as file extension it says the same, still doesn't work.

If i do all this in Windows 7 with the same setup, it all works fine.

Also i checked my event logs when this occurs and this pops up as a keyword "Audit Success" with the text: "An attempt was made to query the existence of a blank password for an account."

Do you have any idea what might cause this?

vallentin
  • 23,478
  • 6
  • 59
  • 81
Ploug
  • 25
  • 1
  • 1
  • 6
  • Your problem is you have to files, a .jar and a .atb, and the only difference is in the file extension. windows can successfully launch the .jar file, but for the .atb you try to open it with "y" and it will not launch? what exactly is "y"? – vandale Mar 22 '14 at 03:37
  • y is just a program that i made. It saves and loads .atb file extensions. I know the only visual difference is the file extension, but the .jar file is an actual program that i can open by just clicking on it. Im not sure you get the actual problem but thanks for trying, but the problem is that in windows 7, it sends the path file of the .atb file to my program, as it SHOULD. But it doesnt do this in windows 8.1 for some reason. Eventhough i can open the .jar file individually, and it will startup my java program. – Ploug Mar 22 '14 at 05:38
  • 1
    Try running your y application as an administrator. Windows 8 is more finicky about permissions than Windows 7. – Gilbert Le Blanc Mar 22 '14 at 07:45
  • I did already, and also as i said i can run the y application individually (even without admin) completely fine. But when i try to open the New Text Document.atb application WITH the y application it just says the message, even when i try to do it all as admin. – Ploug Mar 22 '14 at 16:32

3 Answers3

3

You can't associate file extensions to trigger a .jar file on Windows. The only file types you can trigger on Windows are .exe, .pif, .com, .bat, .cmd, so instead of triggering the .jar file, you can trigger a .bat file, which then launches the .jar file.

Create a y.bat file and place it next to your y.jar file and write the following code inside it:

@echo off
title y
start javaw -jar "C:\Users\SomeUsername\Desktop\y.jar" %1

You can change the title and y.jar path as you please, just remember that the path need to be the absolute path. Though the real keyword here is %1, that is the actual path, of the file you clicked.

You can get the value of any parameter using a % followed by it's numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on

%* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...%255)

Now you can simply right-click on any .abt file and press "Open With...", remember to check "Use this app for all .abt files" and then just browse for the y.bat and click "Open". Now each time you double-click a .abt file it will launch your .jar program.


Additionally I've written this post (Associate File Extension with Java Application) after writing this answer.

vallentin
  • 23,478
  • 6
  • 59
  • 81
1

You can get by without a bat file by running from the command line (with admin privileges)

assoc .xox=Xoxfile

ftype Xoxfile=C:\Program Files\Java\jre1.5.0\bin\javaw -jar c:\dev\work\y.jar %1

(correcting for the path to your current jre and path to your jar).

Since .txt is already a defined filetype in windows, I think you could skip the assoc command and replace Xoxfile above with

ftype "Text Document"=C:\Program Files\Java\jre1.5.0\bin\java -jar c:\dev\work\y.jar

but I've only done this with a new custom file type.

https://www.rgagnon.com/javadetails/java-0592.html

lampreyOne
  • 21
  • 5
0

I had a silly issue with a .JAR opening. After running "java -jar MyApp.jar", I came to the realization that it was not launching the gui as my preferences file was not in the same path as the .jar file.

Adding a check for if(!file)then create new file... the app worked as expected and became easier to port/share.