Results 21 to 32 of 32
Thread: Run a Java program on Windows.
- 07-15-2011, 03:50 AM #21
- 07-15-2011, 03:57 AM #22
Member
- Join Date
- Jun 2011
- Posts
- 19
- Rep Power
- 0

This is what I have. Sorry it's a little small.Last edited by a_programmer; 07-15-2011 at 04:00 AM.
- 07-15-2011, 04:00 AM #23
Is there a javaw.exe file in C:\Program Files\Java\jre6\bin\ folder?
- 07-15-2011, 04:09 AM #24
Member
- Join Date
- Jun 2011
- Posts
- 19
- Rep Power
- 0
Yep. I changed the file association to the java.exe file that's in the same folder as well, but that didn't work so I changed it back to javaw.exe
- 07-15-2011, 04:13 AM #25
Did you get a flash on the screen (the command prompt window quickly opening and closing) when you used the java.exe command vs javaw.exe?
Try taking the command line to the command prompt window and see if it will execute there ok.
Replace the %1 with the jarfile filename.
- 07-15-2011, 04:22 AM #26
Member
- Join Date
- Jun 2011
- Posts
- 19
- Rep Power
- 0
Yes I do get a flash on the screen.
Which command do I use? If I type "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "java.jar" %* it will say "Unable to access jarfile java.jar"
java -jar "java.jar" %* runs fine.
java -jar "java.jar" runs fine too.
- 07-15-2011, 04:32 AM #27
Did you try it without the "s around the jar filename?If I type "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "java.jar" %*
it will say "Unable to access jarfile java.jar"
Also try it with the java.exe command vs javaw.exe
Can you copy and paste here the console:
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
Here is what I get when there jar file does not exist:
D:\Norms\Norms Tools>D:\Java\jre6_20\bin\java.exe -jar asdf.jar
Unable to access jarfile asdf.jarLast edited by Norm; 07-15-2011 at 04:37 AM.
- 07-15-2011, 04:42 AM #28
Member
- Join Date
- Jun 2011
- Posts
- 19
- Rep Power
- 0
Here's what it shows:
Oh, for the "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "java.jar" %* a dialog box would pop up saying "Unable to access jarfile java.jar". It didn't show up in the command prompt.The system cannot find message text for message number 0x2350 in the message fil
e for Application.
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java -jar calc.java
Unable to access jarfile calc.java
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>"C:\Program Files\Java\jre6\
bin\javaw.exe" -jar "calc.jar" %*
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java -jar "calc.jar" %*
Enter infix expression: h
Error in expression. Invalid character.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java -jar "calc.jar"
Enter infix expression: q
Error in expression. Invalid character.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java -jar calc.jar
Enter infix expression: q
Error in expression. Invalid character.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>"C:\Program Files\Java\jre6\
bin\javaw.exe" -jar "java.jar" %*
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>"C:\Program Files\Java\jre6\
bin\javaw.exe" -jar "java.jar" %*
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>"C:\Program Files\Java\jre6\
bin\javaw.exe" -jar java.jar %*
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java calc.jar
Exception in thread "main" java.lang.NoClassDefFoundError: calc/jar
Caused by: java.lang.ClassNotFoundException: calc.jar
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: calc.jar. Program will exit.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>java -jar calc.jar
Enter infix expression: 1 + x
Converted expression: 1 x +
Enter a value for x: 2
The result is: 3
Enter a value for x: q
Not an integer. Exiting.
C:\Users\Brett\Documents\NetBeansProjects\calc\dis t>Last edited by a_programmer; 07-15-2011 at 04:45 AM.
- 07-15-2011, 07:51 AM #29
Member
- Join Date
- Jun 2011
- Posts
- 19
- Rep Power
- 0
I searched frantically on Google but still haven't found an answer. But, I found out I can run dialog boxes.
If I run a dialog box program inside Netbeans with a button that does, the message will print where it normally does in the output box at the bottom.Java Code:System.out.println("Hello, world!");
If I double click the .jar file, the dialog box will come up. When I press the same button, there's no where for Windows to output the text.
- 07-15-2011, 02:46 PM #30
This one seems to have worked. On the other command lines you were referencing non existent jar files.java -jar calc.jar
Does the program attempt to read from the console? I don't know what javaw.exe will do in that case.
Also I don't know what java.exe would do???
Are using a console for input???
- 07-15-2011, 02:46 PM #31
This one seems to have worked. On the other command lines you were referencing non existent jar files.java -jar calc.jar
Does the program attempt to read from the console? I don't know what javaw.exe will do in that case.
Also I don't know what java.exe would do???
Are using a console for input???
- 07-15-2011, 05:45 PM #32
Member
- Join Date
- Dec 2008
- Posts
- 64
- Rep Power
- 0
Java in Windows 7 is bit finicky due to the Win 7 32-bit compatibility mode. What happens to most people is they have a 64-bit version of Windows but install a 32-bit version of Java, when doing this it installs Java in the C:\Program Files (x86)\ and when running java from the command line WIndows will not find it by default. I didn't bother reading all of this thread so this may not be your issue but it may help someone.
Similar Threads
-
One program for both Windows and Linux
By satimis in forum New To JavaReplies: 8Last Post: 04-12-2010, 09:49 AM -
Creating a java program that acts like a normal windows executable?
By rolls in forum New To JavaReplies: 3Last Post: 08-10-2009, 06:34 AM -
Executing java program using windows scheduler
By kanitha in forum New To JavaReplies: 0Last Post: 03-21-2009, 09:16 AM -
How do you start a Java program from the "Start" menu under Windows?
By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 10:04 PM -
How can I make a program look and feel more windows-like?
By Exhonour in forum New To JavaReplies: 1Last Post: 01-16-2009, 10:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks