Java class issues in Ubuntu

Firstly, I am running Ubuntu 9.10

I edited the / etc / environment file to look like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.20" CLASSPATH="/home/travis/freetts/lib/freetts.jar:/home/travis/freetts/lib/jsapi.jar:." 

Then I run "source / etc / environment" to make sure the changes are included. Then I try to compile my simple test program using the following command:

javac Test.java

It produces some errors, but when I compile like this:

javac -cp / home / travis / freetts / lib / freetts.jar: /home/travis/freetts/lib/jsapi.jar :. Test.java

This works fine, does it make me believe that for some reason javac doesn't see the CLASSPATH environment variable? I can repeat it and everything in the terminal:

echo $ CLASSPATH gives me what I insert.

Any help on this would be greatly appreciated.

+4
source share
2 answers

Does it work if you put export in /etc/environment ?

 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.20" export CLASSPATH="/home/travis/freetts/lib/freetts.jar:/home/travis/freetts/lib/jsapi.jar:." 

I assume that CLASSPATH not set before you start using the script, and therefore you only set the local variable.


Here is an illustration of what might happen:

 superman@metro :~$ Z=foo # Only sets for this shell superman@metro :~$ echo $Z foo superman@metro :~$ /bin/bash superman@metro :~$ echo $Z # Not set in sub-processes superman@metro :~$ exit exit superman@metro :~$ export Z # When exported, is part of environment superman@metro :~$ /bin/bash superman@metro :~$ echo $Z # And now visible to sub-processes foo superman@metro :~$ exit exit superman@metro :~$ help export export: export [-nf] [name[=value] ...] or export -p NAMEs are marked for automatic export to the environment of subsequently executed commands. If the -f option is given, the NAMEs refer to functions. If no NAMEs are given, or if '-p' is given, a list of all names that are exported in this shell is printed. An argument of '-n' says to remove the export property from subsequent NAMEs. An argument of '--' disables further option processing. 
+7
source

Have you exported all environment variables to a profile file? I did not see any export command in the file indicated by u ...... use export and try once ......

0
source

Source: https://habr.com/ru/post/1310069/


All Articles