Running Java in Linux Terminal

Bob Smith slyders at ix.netcom.com
Wed Apr 28 21:22:44 UTC 2004


If you're using bash or korn shells you can set the classpath 
environment prior to running java, which could also get you around the 
errors that you are experiencing. 

Java must know the location of any package or packages or group of 
classes that you are going to call during the execution of an 
application, with the exception of the normal Java runtime class 
libraries.  The three options to using Java classpaths are to set the 
entire classpath on the command line ( java -cp [paths] classnames), set 
the classpath in the environment (export CLASSPATH=path1:path2...) or to 
run java from the root class directory that you are using.  I'm not 
going to get into jar file names and packages etc, because that's a 
whole nuther tutorial.

My recommendation is to acquire a good book, or more, on Java.  The Core 
Java Vol.1 book covers extensively how to run Java with various 
classpath definitions, and it's an excellent primer.  There are other 
good books out there too numerous to mention.

HTH,

-Bob

Ryan Golhar wrote:

>The java -cp .... where the .... is your classpath.   It specifies the
>locations of all your classes
>
>What is the error you are getting when you try to run your java program?
>
>-----Original Message-----
>From: redhat-list-bounces at redhat.com
>[mailto:redhat-list-bounces at redhat.com] On Behalf Of Dinh Tien Tuan Anh
>Sent: Wednesday, April 28, 2004 1:58 PM
>To: redhat-list at redhat.com
>Subject: RE: Running Java in Linux Terminal
>
>
>
>
>  Could you explain a little bit clearlier (howtos), I don't know about
>that 
>classpath thing.
>
>  
>
>>From: "Ryan Golhar" <ryangolhar at verizon.net>
>>Reply-To: golharam at umdnj.edu,General Red Hat Linux discussion list
>><redhat-list at redhat.com>
>>To: "'General Red Hat Linux discussion list'" <redhat-list at redhat.com>
>>Subject: RE: Running Java in Linux Terminal
>>Date: Tue, 27 Apr 2004 19:23:40 -0400
>>
>>I think this would be better suited in a java discussion list, but 
>>depending on the error you get, make sure the classes your app needs 
>>are availabie in your classpath.
>>
>>
>>-----Original Message-----
>>From: redhat-list-bounces at redhat.com 
>>[mailto:redhat-list-bounces at redhat.com] On Behalf Of Dinh Tien Tuan Anh
>>Sent: Tuesday, April 27, 2004 5:25 PM
>>To: redhat-list at redhat.com
>>Subject: Running Java in Linux Terminal
>>
>>
>>
>>
>>
>>I'm using NetBeans as the Java editor now. But I can't run any program 
>>in Terminal (by typing java -cp ....). I don't know what I need to be 
>>able do
>>that. In my school, I don't need to modify anything in the Java class,
>>just
>>type java -cp . <File> and run . Please tell me  what I lack.
>>
>>(I hit "man java" but no command for java found)
>>
>>_________________________________________________________________
>>Tired of 56k? Get a FREE BT Broadband connection 
>>http://www.msn.co.uk/specials/btbroadband
>>
>>
>>--
>>redhat-list mailing list
>>unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
>>https://www.redhat.com/mailman/listinfo/redhat-list
>>
>>
>>--
>>redhat-list mailing list
>>unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
>>https://www.redhat.com/mailman/listinfo/redhat-list
>>    
>>
>
>_________________________________________________________________
>It's fast, it's easy and it's free. Get MSN Messenger today! 
>http://www.msn.co.uk/messenger
>
>
>  
>






More information about the redhat-list mailing list