Running java in command prompt (CMD)
Page 1 of 1
m0dm0use




Posts: 171

PostPosted: Mon, 2nd Jan 2012 19:34    Post subject: Running java in command prompt (CMD)
I've been told by my tutor to run CMD open to directory that contains the JAR file...

like this example :

cd c:\JBuilder2\myclasses

To run WriteItemTest ...
java –classpath stockDemo4.jar stockDemo4.WriteItemTest

To run Main ...
java –classpath stockDemo4.jar stockDemo4.Main




I've also tried something I found while searching

C:\Users\User\Desktop\l2>java -jar l2.jar



I've tried these all but can't get it to run

Code:

C:\Users\User\Desktop\l2>java -classpath l2.java l2.Write
Exception in thread "main" java.lang.NoClassDefFoundError: l2/Write
Caused by: java.lang.ClassNotFoundException: l2.Write
        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: l2.Write.  Program will exit.

C:\Users\User\Desktop\l2>
I need to get what I created in jbuilder 3 to run without the need of jbuilder 3 I have the required software upto date.

my program has been created using the deployment wizard in jbuilder3 archive type setup as compressed Jar.


Thanks in advance for any help I get that get this test application working.
Back to top
m0dm0use




Posts: 171

PostPosted: Tue, 3rd Jan 2012 20:41    Post subject:
Please lock topic I've solved this now.

Jar2Exe Wizard 1.8 is also a good tool.

I worked out that this is what it should be
Code:

C:\Users\User\Desktop\jbuilder3\l2>java -classpath l2.jar lecture2.ShopV1
                                                    ^^            ^^
                                          Jar archive    packageName.MainName
It now works also I got it working under cmd much easier than my tutor has explained in the workbooks, also making it an exe with the software is even easier but now I got this solved I am very happy. Now I need to make sure the application saves and opens files as expected.
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group