Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33511 > unrolled thread
| Started by | ruben <ceo@iran.gov> |
|---|---|
| First post | 2016-01-22 15:37 +0000 |
| Last post | 2016-01-23 11:17 +0000 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
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
| From | ruben <ceo@iran.gov> |
|---|---|
| Date | 2016-01-22 15:37 +0000 |
| Subject | java Environment in Manjaro Linux |
| Message-ID | <n7tic6$rbh$4@reader1.panix.com> |
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?
Also, where is the $CLASSPATH set? in the system /etc/profile ? I
should probaly add ./ to the bashrc file?
Ruben
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-01-22 11:16 -0500 |
| Message-ID | <n7tkf8$5p1$1@dont-email.me> |
| In reply to | #33511 |
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
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-01-22 20:44 +0000 |
| Message-ID | <n7u4bq$6d5$1@dont-email.me> |
| In reply to | #33511 |
On Fri, 22 Jan 2016 15:37:43 +0000, 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
>
You don't show how you compiled the source file.
>
> this works however:
>
> [ruben@localhost cs664s16]$ java helloworld Bonjour le monde !
>
In that case helloworld.class, as output by the compiler, must be in
CLASSPATH somewhere.
what does "ls" show when run in the directory holding helloworld.java?
what does "sudo updatedb; locate helloworld.class" show? Be patient: it
make take a few minutes to run if you haven't run updatedb recently.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
[toc] | [prev] | [next] | [standalone]
| From | ruben <ceo@iran.gov> |
|---|---|
| Date | 2016-01-22 21:10 +0000 |
| Message-ID | <n7u5sm$lus$1@reader1.panix.com> |
| In reply to | #33516 |
On Fri, 22 Jan 2016 20:44:42 +0000, Martin Gregorie wrote: > You don't show how you compiled the source file. > with javac > >> this works however: >> >> [ruben@localhost cs664s16]$ java helloworld Bonjour le monde ! >> > In that case helloworld.class, as output by the compiler, must be in > CLASSPATH somewhere. > yes > what does "ls" show when run in the directory holding helloworld.java? > [ruben@localhost cs664s16]$ ls -l total 20 -rw-r--r-- 1 ruben users 432 Jan 22 10:30 helloworld.class -rw-r--r-- 1 ruben users 127 Jan 22 10:30 helloworld.java -rw-r--r-- 1 ruben users 430 Jan 22 10:46 Main.class -rw-r--r-- 1 ruben users 173 Jan 22 09:43 Main.java -rw-r--r-- 1 ruben users 28 Jan 22 08:47 README.md > what does "sudo updatedb; locate helloworld.class" show? Be patient: it > make take a few minutes to run if you haven't run updatedb recently. locate/updatedb will not search my home directory, in my setup, regardless how often it runs [ruben@localhost cs664s16]$ find /home/ruben/ -iname "helloworld*" -print /home/ruben/src/grad_school/compiler/cs664s16/helloworld.class /home/ruben/src/grad_school/compiler/cs664s16/helloworld.java /home/ruben/.cpan/build/Perl6-Pugs-6.2.13-PTKdk7/ext/WTemplate/examples/ helloworld.tpl /home/ruben/.cpan/build/Perl6-Pugs-6.2.13-PTKdk7/ext/WTemplate/examples/ helloworld.pl /home/ruben/.cpan/build/Perl6-Pugs-6.2.13-PTKdk7/misc/pX/Common/AST- Design/Perl5/helloworld.in /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/152/0/.cp/cheatsheets/HelloWorld.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/152/0/.cp/cheatsheets/HelloWorldSWT.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld-composite.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld/helloworld-feature.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld/helloworld-create.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld/helloworld-install.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld/helloworld-extension.xml /home/ruben/.eclipse/ org.eclipse.platform_4.4.2_1543616141_linux_gtk_x86_64/configuration/ org.eclipse.osgi/190/0/.cp/cheatsheets/helloworld/helloworld-update.xm
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-01-22 22:25 +0000 |
| Message-ID | <n7ua9a$q5m$2@dont-email.me> |
| In reply to | #33517 |
On Fri, 22 Jan 2016 21:10:46 +0000, ruben wrote: > On Fri, 22 Jan 2016 20:44:42 +0000, Martin Gregorie wrote: > > >> You don't show how you compiled the source file. >> >> > with javac > OK >> what does "ls" show when run in the directory holding helloworld.java? >> >> > [ruben@localhost cs664s16]$ ls -l > total 20 -rw-r--r-- 1 ruben users 432 Jan 22 10:30 helloworld.class > -rw-r--r-- 1 ruben users 127 Jan 22 10:30 helloworld.java -rw-r--r-- 1 > ruben users 430 Jan 22 10:46 Main.class -rw-r--r-- 1 ruben users 173 Jan > 22 09:43 Main.java -rw-r--r-- 1 ruben users 28 Jan 22 08:47 README.md > OK, so javac is working as expected and putting the .class file alongside the .java file it was compiled from. Note that none of java helloworld.java java helloworld.class java ./helloworld will run on my system either because 'java' it is using the name as a class name, which in your class is simply 'helloworld', and searching through CLASSPATH and the current directory for it. >> what does "sudo updatedb; locate helloworld.class" show? Be patient: it >> make take a few minutes to run if you haven't run updatedb recently. > > locate/updatedb will not search my home directory, in my setup, > regardless how often it runs > How odd. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-01-22 23:11 +0000 |
| Message-ID | <n7ucv5$cgs$1@dont-email.me> |
| In reply to | #33521 |
On Fri, 22 Jan 2016 22:25:46 +0000, Martin Gregorie wrote: > Note that none of > > java helloworld.java > java helloworld.class > java ./helloworld > > will run on my system either because 'java' it is using the name as a > class name, which in your class is simply 'helloworld', and searching > through CLASSPATH and the current directory for it. > However, something like this: java -classpath /home/kiwi/compiler_tests/hello_world helloworld does work because its redefined the classpath to be just: the standard Java SE class library /home/kiwi/compiler_tests/hello_world -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-01-22 20:45 -0500 |
| Message-ID | <n7ulvt$16b6$1@gioia.aioe.org> |
| In reply to | #33511 |
On 1/22/2016 10:37 AM, ruben wrote: > Also, where is the $CLASSPATH set? in the system /etc/profile ? I > should probaly add ./ to the bashrc file? I will recommend against using CLASSPATH env var. Arne
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-01-23 11:17 +0000 |
| Message-ID | <n7vngt$154$1@dont-email.me> |
| In reply to | #33523 |
On Fri, 22 Jan 2016 20:45:31 -0500, Arne Vajhøj wrote: > On 1/22/2016 10:37 AM, ruben wrote: >> Also, where is the $CLASSPATH set? in the system /etc/profile ? I >> should probaly add ./ to the bashrc file? > > I will recommend against using CLASSPATH env var. > Agreed - sort of. I find $CLASSPATH convenient during development, but almost always end up running developed, live code from a bash script that sets the java -classpath option. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web