Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

Java doesn´t find the CLASSPATH (System variable)

Homework & Coursework Questions


Tags
classpath, directory, java javac, system variable

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-19-2016
MenschTown MenschTown is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 20 April 2016, 6:21 AM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Java Java doesn´t find the CLASSPATH (System variable)

1. The problem statement, all variables and given/known data:

As a excercise I have to compile a program (Hello2.java) with a class file (HelloText.java) in another directory. (As you seen in the screenshot)
I´m setting a PATH and a CLASSPATH (system variables). It´s working without a command. But if I use a command like java or javac which I need to compile ITS NOT WORKING.
I can´t retrace why the bash is doing this respectively is not doing this.

2. Relevant commands, code, scripts, algorithms:

PATH=$PATH:<directory>, CLASSPATH =$CLASSPATH:<directory>, cd (change directory), javac

3. The attempts at a solution (include all code and scripts):

see the screenshot.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Beuth Hochschule für Technik, Berlin, Germany, Radners, Programmierung I (Praxis)
Attached Thumbnails
Java doesn´t find the CLASSPATH (System variable)-problem-png  
Sponsored Links
    #2  
Old Unix and Linux 09-26-2016
rovf rovf is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 23 January 2017, 8:31 AM EST
Posts: 134
Thanks: 18
Thanked 25 Times in 21 Posts
You didn't set the environment variable CLASSPATH, but a shell variable of this name, i.e. only the shell sees this. What you did here is similar to setting a variable in your Java program, then run a shell program from Java and hope that the Java variable is visible to the shell program.

In shell context, "environment variables" are sometimes also called "exported variables", because the child processes can see them. Each shell has a different way to set an environment variable. For example, bash or zsh use the command export, while csh or tcsh use the command setenv.

You didn't specify, which shell you are using. Consult the man page of your shell to find out, how to set environment variables.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Fedora java classpath cokedude UNIX for Advanced & Expert Users 0 10-01-2013 09:21 PM
Classpath of JAVA yifangt Programming 1 01-11-2013 07:38 PM
Trouble setting up Java classpath Israel213 Ubuntu 0 03-02-2011 05:18 AM
regarding classpath java PRKS Programming 1 12-24-2009 04:38 AM
exit status running java classpath in unix shell mmcds Programming 2 08-02-2007 11:06 PM



All times are GMT -4. The time now is 10:39 AM.