Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33514
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: java Environment in Manjaro Linux |
| Date | 2016-01-22 11:16 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <n7tkf8$5p1$1@dont-email.me> (permalink) |
| References | <n7tic6$rbh$4@reader1.panix.com> |
On 1/22/2016 10:37 AM, ruben wrote:
> I'm testing the java developers environment and its not working as I
> expected
>
> [ruben@localhost cs664s16]$ cat ./helloworld.java
> public class helloworld {
> public static void main(String[] args) {
> System.out.println("Bonjour le monde !");
> }
>
> }
>
>
> [ruben@localhost cs664s16]$ echo $CLASSPATH
> /home/ruben/GNUstep/Library/Libraries/Java:/root/GNUstep/Library/
> Libraries/Java:/usr/lib/GNUstep/Libraries/Java:.:./
>
>
> [ruben@localhost cs664s16]$ java ./helloworld.java
> Error: Could not find or load main class ..helloworld.java
>
>
> this works however:
>
> [ruben@localhost cs664s16]$ java helloworld
> Bonjour le monde !
>
>
>
> So, I am completely confused. How can it not take the specified file
> name to run?
`helloworld.java' is a source file full of Java source code.
The corresponding class file (produced by the javac compiler) would
be `helloworld.class'. If you're familiar with languages like C or
C++, this is similar to the distinction between `helloworld.c' and
`helloworld.o'.
Furthermore, the java command itself doesn't want either file
name: It just wants the class name `helloworld', and it knows to
look for `helloworld.class' in "various places." In your case it
will find `helloworld.class' as an ordinary file in one of the
directories listed in CLASSPATH, but there are other possibilities
that can be used in other setups. It might find `helloworld.class'
as one member of a "jar file" (a specially-formatted ZIP archive),
or it might be told to load `helloworld.class' from the network,
and still other even more exotic setups can be concocted. The
upshot, though, it that you tell Java the unadorned class name,
not the name of a file.
> Also, where is the $CLASSPATH set? in the system /etc/profile ? I
> should probaly add ./ to the bashrc file?
Sorry; I have no idea what piece of script sets your CLASSPATH.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
java Environment in Manjaro Linux ruben <ceo@iran.gov> - 2016-01-22 15:37 +0000
Re: java Environment in Manjaro Linux Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-01-22 11:16 -0500
Re: java Environment in Manjaro Linux Martin Gregorie <martin@address-in-sig.invalid> - 2016-01-22 20:44 +0000
Re: java Environment in Manjaro Linux ruben <ceo@iran.gov> - 2016-01-22 21:10 +0000
Re: java Environment in Manjaro Linux Martin Gregorie <martin@address-in-sig.invalid> - 2016-01-22 22:25 +0000
Re: java Environment in Manjaro Linux Martin Gregorie <martin@address-in-sig.invalid> - 2016-01-22 23:11 +0000
Re: java Environment in Manjaro Linux Arne Vajhøj <arne@vajhoej.dk> - 2016-01-22 20:45 -0500
Re: java Environment in Manjaro Linux Martin Gregorie <martin@address-in-sig.invalid> - 2016-01-23 11:17 +0000
csiph-web