aspose file tools*
The moose likes Java in General and the fly likes standalone application question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "standalone application question" Watch "standalone application question" New topic
Author

standalone application question

Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
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


Any help is appreciated. Thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39543
    
  27
What is the internal structure of the jar file? In other words, where is that missing class? You can use "jar tf XYZ.jar" to find out.


Ping & DNS - updated with new look and Ping home screen widget
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
"dist" is the unzipped folder I distributed over to Windows.

scott@richmond:~/extract/dist$ jar tf DTVControl.jar

META-INF/
META-INF/MANIFEST.MF
META-INF/services/
dtvcontrol/
dtvcontrol/resources/
dtvcontrol/resources/busyicons/
META-INF/services/org.jdesktop.application.Application
dtvcontrol/DTVControlApp.class
dtvcontrol/DTVControlView$1.class
dtvcontrol/DTVControlView$10.class
dtvcontrol/DTVControlView$11.class
dtvcontrol/DTVControlView$12.class
dtvcontrol/DTVControlView$13.class
dtvcontrol/DTVControlView$14.class
dtvcontrol/DTVControlView$15.class
dtvcontrol/DTVControlView$16.class
dtvcontrol/DTVControlView$17.class
dtvcontrol/DTVControlView$18.class
dtvcontrol/DTVControlView$19.class
dtvcontrol/DTVControlView$2.class
dtvcontrol/DTVControlView$20.class
dtvcontrol/DTVControlView$21.class
dtvcontrol/DTVControlView$22.class
dtvcontrol/DTVControlView$23.class
dtvcontrol/DTVControlView$24.class
dtvcontrol/DTVControlView$25.class
dtvcontrol/DTVControlView$26.class
dtvcontrol/DTVControlView$27.class
dtvcontrol/DTVControlView$28.class
dtvcontrol/DTVControlView$29.class
dtvcontrol/DTVControlView$3.class
dtvcontrol/DTVControlView$30.class
dtvcontrol/DTVControlView$31.class
dtvcontrol/DTVControlView$32.class
dtvcontrol/DTVControlView$33.class
dtvcontrol/DTVControlView$34.class
dtvcontrol/DTVControlView$35.class
dtvcontrol/DTVControlView$36.class
dtvcontrol/DTVControlView$37.class
dtvcontrol/DTVControlView$38.class
dtvcontrol/DTVControlView$39.class
dtvcontrol/DTVControlView$4.class
dtvcontrol/DTVControlView$40.class
dtvcontrol/DTVControlView$41.class
dtvcontrol/DTVControlView$42.class
dtvcontrol/DTVControlView$5.class
dtvcontrol/DTVControlView$6.class
dtvcontrol/DTVControlView$7.class
dtvcontrol/DTVControlView$8.class
dtvcontrol/DTVControlView$9.class
dtvcontrol/DTVControlView.class
dtvcontrol/resources/AboutBox.properties
dtvcontrol/resources/DTVControlAboutBox.properties
dtvcontrol/resources/DTVControlApp.properties
dtvcontrol/resources/DTVControlView.properties
dtvcontrol/resources/about.png
dtvcontrol/resources/arrow-3D-green-down25.png
dtvcontrol/resources/arrow-3D-green-left25.png
dtvcontrol/resources/arrow-3D-green-right25.png
dtvcontrol/resources/arrow-3D-green-up25.png
dtvcontrol/resources/arrow-3D-green-up40.png
dtvcontrol/resources/busyicons/arrow-3D-green-up40.png
dtvcontrol/resources/busyicons/busy-icon0.png
dtvcontrol/resources/busyicons/busy-icon1.png
dtvcontrol/resources/busyicons/busy-icon10.png
dtvcontrol/resources/busyicons/busy-icon11.png
dtvcontrol/resources/busyicons/busy-icon12.png
dtvcontrol/resources/busyicons/busy-icon13.png
dtvcontrol/resources/busyicons/busy-icon14.png
dtvcontrol/resources/busyicons/busy-icon2.png
dtvcontrol/resources/busyicons/busy-icon3.png
dtvcontrol/resources/busyicons/busy-icon4.png
dtvcontrol/resources/busyicons/busy-icon5.png
dtvcontrol/resources/busyicons/busy-icon6.png
dtvcontrol/resources/busyicons/busy-icon7.png
dtvcontrol/resources/busyicons/busy-icon8.png
dtvcontrol/resources/busyicons/busy-icon9.png
dtvcontrol/resources/busyicons/idle-icon.png
dtvcontrol/resources/nebula.png
dtvcontrol/resources/splash.png
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
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?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36468
    
  16
If you get the "not recognised" error message it usually means a PATH error. Look here, or here, or here (ยง 4).

Are your .jars associated with "javaw.exe" in Control Panel?
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
All the control panel tells me is that .jar is associated with Java Platform SE binary.
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
I did the routine of using Browse to find javaw. Then I opened it and presumably it was associated.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36468
    
  16
If it is associated with "Java Platform" I would assume that is correct until proven otherwise. Did you get your PATH sorted out?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

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
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
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.
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

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

Regards
Prem
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

prem pillai wrote:2) set path=

5) set path=%java_home%\bin

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.
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

You loose all system tools from C:\Windows\system32 as well.

This will happen only in the current command window .... !!! Not a big deal ...

I put those steps intensionally to avoid any unwanted paths.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

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
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.
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

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 ..."


Did you do it in the same command window where your have set the java_home & path variable Or in a new command window?

Can you attach a screen shot of the steps you are doing?
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
Did it in the same window and it failed. Did it again with a new console window and it also failed. How do I take a screen shot?
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

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
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.

Thanks for the help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

How did you change the directory? From the prompt, using the "cd" command? If so, do you use an absolute path in the JAVA_HOME variable?
Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
cd C:\Program Files(x86)\Java\jre6\bin

I used the absolute path.
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

I have attached a help file (help.jpg).

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 .



[help.jpg]

Scott A Burch
Ranch Hand

Joined: Jan 04, 2011
Posts: 50
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
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.

Thanks to all for the help and advice.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: standalone application question
 
Similar Threads
Manifest file with ant
Jar generated with ant will not use manifest class-path
Building a jar with dependancies.
NoClassDefFoundError running a jar file from the command line
Finding main class problem