1
I made an application in Java and I want to open a certain type of file in it, like with Netbeans, that is when a person clicks on the file ". java " it opens in Netbeans( or another IDE that accepts this type of file).
However, even if I configure the file to open in my application, when it is opened, it does not show its contents in my application.
Are there any java commands to do this ?
To+
EDITED :
It’s all over the place, but I’m not doing it right. I know how to open a file ( I already have a method for this), but I can’t call it in passing the path because it gives error.
follows the code:
// essa é uma das minhas classes ,é ela que é chamada e possui todos os componentes visuais
public static void main( String args[]) {
public void run() {
new Programa().setVisible(true);
if(args.length > 0) {
try {
MetodoAbir(args[0])
}catch(Exception erro) {
}
}
But the error says that the method can not be "refenrenciated by Static contex". This occurs even if I put a method without parameter, ie I can not call the methods there. I also tried to create a global variable and play the value args[0] in it to pass to the method in another location but also gives the same error.
Do you want to set your program as default in windows, or do you want to run some application within it? It is not clear that in question.
– user28595
I set it as default. I want to run something inside it, but when I click on the file the application opens but does not show the contents of the file.
– Ronaldo
You are probably getting the file path as parameter, but you are not doing anything with it.
– Reginaldo Rigo
Add the code responsible for this execution by clicking EDIT on the question.
– user28595
How so, in the code I have to do a check to know if someone externally clicked on a file when opening the application ? If yes, how do I do it ?
– Ronaldo
@diegofm , that’s what I’m wondering how to check if any file was externally clicked to open it in the application. I only know how to do it using jfilechooser .
– Ronaldo
What have you done so far? Add that to the question, your question we already know, now you need to show where you want to put it and how is the current code where you want to add this feature.
– user28595