0

I'm really worries that registry editing is going in the wrong direction, and possibly messing things up badly.
How do you know its not working when you double click it? It only shows console I/O and the default setup does not have a console when you double click because that uses javaw. It could be running and you wouldn't know it.
Try putting something in your program that will actually show when you double click it, eg

JOptionPane.showMessageDialog(null, "hello", "hello", JOptionPane.INFORMATION_MESSAGE);

you'll need to import javax.swing.JOptionPane;

0

That's the "can't find or open the main class "? It looks like your changes to the registry may have messed up the (correct) defaults established by the JDK/JRE installer. Presumably you backed up the registry settings befroe changing them, so it may be a good idea to restore the original settings and try again with the option pane.

0

Um, did this :

C:\>assoc .jar=jarfile
C:\>ftype jarfile="C:\Program Files\Java\jre\bin\javaw.exe" -jar "%1" %*
C:\>ftype jarfile="C:\path\to\your\javaw.exe" -jar "%1" %*

change the registry value ? If yes , then no I do not have an backup :( .

0

I found this which claims to be a ble to restore a broken file assoxciation for jar files. I've never used it myself, but it may get you out of trouble... (at your own risk)

0

In the registry, did you find the jarfile entry? What was it?
What you posted looked like the entry for .jar.
Use the export command to save the entries to a disk file that can be copied and pasted here.

0

@Jamescherrill , after I used that jar file fixer , the program ran and said hello(JOptionPane.showMessageDialog(null, "hello", "hello", JOptionPane.INFORMATION_MESSAGE);
you'll need to import javax.swing.JOptionPane;) But after that it closes . My program never comes up .

Edited by im abcd

0

the program ran and said hello

If any part of the program executed, then you have the correct settings in the registry.

You need to look at debugging your code to see why it is not doing what you want.
What happens when you execute the code manually by openning a command prompt window and entering the java -jar ... command?

0

It doesn't come upo because it only uses the console and when you use javaw to run the jar java does not open a console window, so you can#t see your program.
Basically, console apps and double click jars don't mix.

0

If your program is a console program, use java vs javaw to execute it.
Add a Scanner class object and at the end of the program call a method that will block until the user enters some data.

0

Sorry if I being dumb but can you show me an example ? What do you mean by java vs javaw ?

0

There are two versions of the program you use to execute your java classes, java.exe and javaw.exe
The only difference between them is that java.exe opens a console window where you can see your console output and enter data. Because most java programs do not use the console, there is also javaw.exe which does not open a console window. javaw.exe is the default exe that is run when you double-click a jar, but it is usless for programs like yours that use the console for outout and input.

0

So technically my program cannot be distributed among my friends ? :( or is their some way ( other than reprogramming the entire thing to work in javaw.exe) to make it work ?

1

Certainly the obvious advice is to update your program to use a GUI. This is 2012, and console-based end-user applications just aren't written any more (except in the early stages of learning Java).
You could distribute it with a tiny batch file that just has the single line
java -jar Apollonius_Theorem.jar
then they could double-click the batch file

0

Thank you :) . I can run it properly now . Anyways I would be getting into using GUI later as I have just started java :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.