I'm working on a media player using JavaFX right now and I would like to set it as the standard program to open .mp3 files in the future.
I know how to change the standard program. But when the user double clicks a specific file and my program opens up how would I be able to get the path to the file the user clicked on?
Thanks in advance!
This is the way I made it work:
I exported my program from Eclipse. Then I opened an mp3 file using the program but I got an error message saying something like this: "Invalid Win-32 application".
Having used Launch4j before, I tried wrapping my file in an exe file, which made it work perfectly.
I don't know if you are able to set a jar file as a standard program in other OSs, but you can't in Windows, unfortunately. But at least the OS gives you the path to the file the user clicked on!
Thanks again to #James_D !
Related
Every time I try to save a.jar file for my programming course and it doesn't open, and yes I save the META.MF whit the correct path, I even stop making them on the Terminal and use Net Beans but same problem Error: Could not find or load main class a3t8e1.A3T8e1 maybe I need to download something else.
I search on the internet and download the jar launcher but nothing better.
this is the .jar unpacked
Please try to right click the .jar file and click the Get Info. Under the Open with, select the Jar Launcher.app. After that, try to reopen your related .jar file.
This question already has answers here:
Audio does not play in Jar but does in eclipse
(4 answers)
Closed 7 years ago.
I've got a problem regarding audio.
I am coding in Java using Netbeans, and I want to export my project so that it doesn't require Netbeans to run, so I decided to create a JAR File. I put all the images, and audio files (aiff) for my program in the src folder so that they could be accessible from outside the coding console.
I have declared my InputStream and AudioStream as global variables, and I am using them within a try catch block, where the code is run when a button is clicked.
AudioPlayer.player.stop(audios);
try{
in = new FileInputStream (new File("src/glory.aiff"));
System.out.println("Button Clicked");
audios = new AudioStream (in);
AudioPlayer.player.start(audios);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
This code perfectly fine when I run the program on Netbeans, however when I create a JAR file, the audio doesn't play, and an error pops up saying that the file cannot be found. I've tried this on my computer, and other computers, and the same problem occurs.
What I find strange, is that the pictures I mentioned earlier are in the same SRC folder, and they display correctly. I have linked these pictures through the use of icons, and Netbeans auto-generates code for that.
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMG_2138.JPG")));
I have done research of my own, however other people who have this problem don't seem to be using the same AudioStream as myself and I don't know how to adapt it to solve my problem! I've also tried changing the file path of the audio, but whenever it has worked in Netbeans, it has not worked in my JAR file.
Would anyone please be able to tell me how I could fix this problem?
Thanks,
Rohan
I think it would be easier for you to create an setup for your java program in Netbeans and it will still be able to run without Netbeans.
You can do so using a software called excelsior jet.
All you would need to do is watch a short 5 min video on youtube on how to use this and you will have your setup which you can install in your computer and other computers.
Also before you use the software to make the setup it would be good for you to check whether your program actually runs properly as a jar file.
To do so just go to where you save your Netbeans projects, click the project for your program and then enter the "dist" folder(This is where the jar file for project is stored). Click the jar file to check whether the project runs normally.
If you do not find your jar file in the dist folder then its most probably because you tampered with your "manifest.mf" file or your "build.xml" file in your java project.
Provided is what my Netbeans program looks like right now, I've been trying to google this for hours but have found nothing that has helped. For an assignment I am supposed to open the 'Dealership.class' class and modify it, when I do the following nothing happens;
Double clicking the .class file
file > open file > dealership.class
dragging dealership.class into the editor window
When I double click the file I get an error from Netbeans saying "Cannot open, no source".
Can anyone tell me why this is occurring?
What my Netbeans looks like via Gyazo
Don't open the class file, open
Dealership.java
Instead, that is the uncompiled text version that is readable
If you don't have dealership.java,
There is No way when using normal IDEs.
Use JD to decompile the file to a .java and open it.
In my registry, for the extension '.conf' I made the (Default) value point to the pathway of my App. However when I try clicking a file with the extension '.conf' the window asking the user to select a program still opens, rather than simply opening the app associated with the extension. Am I declaring something wrong?
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.conf]
#="C:\\Users\\izhodzis\\workspace\\ConfCompiler\\src\\ConfCompiler.jar"
PS. The idea is that it will work on other peoples' computers. They shouldn't need to select "Always use the selected program to open this kind of file"
Your regedit should look something like this: PATH_TO_JAVAW -jar PATH_TO_CONFCOMPILER
"C:\\Program Files\\Java\\j2rex.y.z\\bin\\javaw.exe -jar C:\\Users\\izhodzis\\workspace\\ConfCompiler\\src\\ConfCompiler.jar"
That probably won't work but hopefully it would help you further.
Wondering if anyone can tell me why trying to open a .jar file with Win7 Explorer ("Open With" C:\Windows\explorer.exe) would cause the computer to continually create (over 200+ in a couple seconds) explorer processes?
Thanks!
Maybe do you want to view the contents of the jar? Take a look to this page. Or try with what is written on this page if you want to execute the jar without the command shell.
EDIT:
The problem of windows explorer is described in this page and in this too.
I'm wondering why you are trying to open a jar file using Windows Explorer...change the properties...set it to run with java.exe....everything should be fine...and coming to the 200+ question...unless it is a virus or something, it should not behave in such a way...strange to see that happen....try opening other jars in a similar way...you'll get to know the problem and the eventual solution...
Had the same problem with opening JAR files.
From here(thanks Alberto Solano):https://social.technet.microsoft.com/Forums/windows/en-US/9237ca68-645c-4718-9a51-24788f312c4b/windows-7-hangs-when-opening-a-file-with-explorerexe?forum=w7itproperf
This works(thanks MVied):
Run Registry Editor
Browse to \HKEY_USERS\S-1-5-21-(random numbers with dashes)\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts(whatever file extension is broken, i.e. '.jpg')\
Delete the folder called 'UserChoice'