I am trying to make my application stand alone. It was developed on a linux box with Netbeans 6.9.1, and I have taken the jar file to a Windows 7 laptop and tried to launch the app. I get the following error message: "Could not find the main class: dtvcontrol.DTVControlApp. Program will exit." Laptop has a fresh install of Java 6_24. It will launch from the console of the linux box.
Below is my manifest in the jar file:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.6.0_20-b20 (Sun Microsystems Inc.)
Main-Class: dtvcontrol.DTVControlApp
Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/be
ansbinding-1.2.1.jar
X-COMMENT: Main-Class will be added automatically by build
I'll quote myself from a similar thread posted in the Beginning Java forum earlier today:
Rob Spoor wrote:Also, try to run your JAR file from the command line first, using "java -jar <jarfile>". When you double click a JAR file it's using the javaw tool which unfortunately shows the same error message (class not found or something like that) for any exception or error that is thrown from the main method. By using the command line you can see those exceptions / errors.
I tried running my application from the Windows 7 console. I get "java is not recognized as an internal or external command, operable program, or batch file" ...
Jar files are associated with Java in the Control Panel. Any ideas?
To me it looks like everything is set up correctly on the Windows box. But when you checked the contents of the jar file, you checked the version on the Linux box, did you not? Whereas the actual problem is with the version on the Windows box. This suggests the possibility that the jar might have been corrupted in the process of transmitting it there. (This could happen if for example you sent it via FTP using ASCII mode.) So check the jar on the Windows box.
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
What app can I use to check it? I use gedit on linux; is there an equivalent on Windows?
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
I checked the details on the box that tells me it can't find the main class and it shows the path to javaw exactly right.
Let me assume that, DTVControl.jar is present in your c:\test directory and java version 1.6 is installed on C:\Program Files\Java directory.
In windows , open a command prompt, and execute the following commands.
1) cd c:\test
2) set path=
3) set java_home=
4) set java_home=path to your java installation directory ; For example, set java_home=C:\Program Files\Java\jre6
5) set path=%java_home%\bin
Now just a check if java is available in the path
6) java -version
This should output the the current java version in your windows machine (some thing like "java version "1.6.xxx""). ie; you should not be seeing the "java is not recognized .." message this time if your java_home path is correct.
Now you can try running your application using the command
7)java -jar DTVControl.jar
Yeah, bad idea. Definitely a bad idea. You loose all system tools from C:\Windows\system32 as well. Better get rid of step 2, and replace step 5 with "set PATH=%JAVA_HOME%\bin;%PATH%". That way you put the JDK's bin folder before the existing path.
Scott A Burch wrote:What app can I use to check it? I use gedit on linux; is there an equivalent on Windows?
Rename it from x.jar to x.zip and then double-click it.
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
Did the above --- skipped step 2 and changed step 5. Console showed me the proper version of Java in the JRE folder. I tried to launch the app using "java -jar DTVControl.jar" and got the same reply " java is not recognized as an internal or external command ..."
Could this be some kind of permission problem? The app iself is executable in the properties window.
press print-screen [PrtSc] key in your key board , open a word document Or MS paint , press Cntrl + V.
Then attach it here.
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
I did the steps again according to Rob's modification above, and was able to get the "java -version" command to give me the proper response. When I changed the directory to the one that holds my application, it says Java is not recognized.
I have an email into my sysadmin to see if there's a reason why Java won't run.
1) Save help.jpg file to your machine
2) Rename it to help.bat 3) Open the help.bat in a text editor (notepad). I have added comments in the file to modify some variables. Follow that carefully.
3.a) Replace "D:\test2\test.jar" using the absolute path to your jar file.
3.b) Replace "C:\Program Files\Java\jre6" using the absolute path to your java installation directory.
3.c) Save the file.
4) Open a command window
5) Change directory to the folder where you have saved help.bat
6) Type the command .\help.bat and press enter.
Send me the output of the above command to me .
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
I downloaded a copy of HJSplit for Java onto my Windows 7 laptop and it launched fine when doubleclicking the jar file in the Downloads folder. The only I did differently was to uninstall and reinstall the latest Java using "run as administrator". So it's not the path after all, or a suspect installation of Java, but my coding of my app. Any other suggestions as to what might be wrong?
Scott A Burch
Ranch Hand
Joined: Jan 04, 2011
Posts: 50
posted
0
I got it to launch on Windows. Somewhere along the way, an external library required for operation was deleted from the distribution. The comment early on was most accurate: the distribution to Windows was corrupted. Once I put it back, the program launched as intended.