Startup scripts

Forum Forums New users Welcome to antiX Startup scripts

  • This topic has 9 replies, 6 voices, and was last updated Jan 22-3:59 pm by techore.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #128247
    Member
    GeordieProgrammer

      Hi everyone. I’m trying AntiX 23 on an Acer Aspire 5734Z I received for Christmas 2011. This is a 64-bit laptop with 4 GB RAM.

      My prior Linux experience is with RHEL, Mint, Ubuntu, and Lubuntu.

      To install JDK on Ubuntu, I would:

      1. Download OpenJDK and extract to e.g. /usr/lib/jvm/jdk-20
      2. Create the file /etc/profile.d/jdk.sh, and set permissions to 755.
      3. Add the below content to jdk.sh:

      export JAVA_HOME=/usr/lib/jvm/jdk-20
      export PATH=$PATH:$JAVA_HOME/bin

      Having tried this on AntiX: $JAVA_HOME does not exist after logging in – it’s as if that script simply hasn’t been run. I’m thinking that startup script behaviour on AntiX must be different to Ubuntu?

      On a separate note: as anyone who had been using Lubuntu to keep 32-bit machines usable will know, software updates stopped being provided for 32-bit in May 2023. I have therefore also installed AntiX to:

      Dell Dimension 5150: 32-bit desktop from 2006 with 3 GB RAM (originally sold with 1 GB, but I added more a couple of years ago).
      Acer Advent: 32-bit Netbook purchased 2008 with 1 GB RAM.

      #128248
      Moderator
      Brian Masinick

        It’s possible to install JDK on antiX but your assumption that various variables and conditions are the same as Ubuntu is incorrect. Everything needed to get a Java environment installed and configured must be done by hand.

        As I said, it’s possible but far from trivial. Unless you have a list of every variable, configuration step or a procedure that will do 100% of that I recommend either using a platform your tool is designed for or find instructions on how to put each component in place.

        I’ve worked with Java, JRE and JDK before. There’s a lot that goes in to building the environment and I do believe that there are complete environments. Most of them are not free but they are comprehensive and complete.

        --
        Brian Masinick

        #128251
        Member
        anti-apXos

          My understanding is that /etc/profile only runs for login shells. So if you switch to tty2 (CTRL+ALT+F2) and login, you should see your env variables there. I just tested that and it seems to be working on my antix-23 system.

          Once you’re on a desktop, if you open up a terminal window like ROXterm or urxvt, that’s a non-login shell, so it won’t have read /etc/profile. As far as I know, this is standard unix behavior. If Ubuntu and RHEL read /etc/profile in non-login shells that would be the exception.

          For non-login bash shells, you can add env variables in ~/.bashrc (per user) or /etc/bash.bashrc (all users).

          EDIT: There’s also non-interactive shells, like when you run a script. I don’t know if those are relevant to OpenJDK, but if they are, environment variables set in bashrc won’t work for them. I have used /etc/environment to set variables that I also want in non-interactive shells. Environment variables set there affect all types of shell.

          • This reply was modified 3 months, 2 weeks ago by anti-apXos.
          #128271
          Member
          sybok

            The explanation by @anti-apXos is nicely formulated also at:
            https://askubuntu.com/questions/438150/why-are-scripts-in-etc-profile-d-being-ignored-system-wide-bash-aliases

            Also, I assume that the OpenJDK version required is 20 (available in unstable|sid-repositories) in and not 17 (avail. in stable-repositories).
            I.e. installing (on a stable system) from repositories is not an option.

            #128304
            Member
            GeordieProgrammer

              Thanks to everyone for the replies.

              The terminology ‘login shells’ and ‘non-login shells’ I haven’t heard before, sounds like something to read up on. However adding to .bashrc seems like it will be the answer here, at least for setting the environment variables. This is a much more universal solution isn’t it; files in /etc/profile.d is an Ubuntu solution but I’ve not seen it on another distro.

              Java 17 from stable-repositories will do nicely for what I need. sudo apt install openjdk-17-jdk presumably.

              Power supply unit has failed today for this laptop so will now be a few days before I can confirm what works.

              #128312
              Moderator
              Brian Masinick

                @geordieprogrammer sorry for my previous comments; I think that I misread part of your original post, but I’m very happy to see that others correctly read and understood what you originally questioned.

                As far as “login” scripts, when you are using sh family shells, such as sh, ksh, and bash, it is POSSIBLE, but not mandatory, to have a .profile. Often in the .profile, it will have a test for the existence of a .bashrc file, and sometimes also the existence of a .bash_aliases file; if either of them exist, .profile will execute them, but the main thing to know about .profile is that unless you run it explicitly, it otherwise runs only at login.

                In any sh family shell, you can run the shells that work with them by either using the dot syntax, e.g.
                . ~/.bashrc or by specifying the function that . performs, that is “source”,
                source ~/.bashrc, and if this is done, the capabilities of this file can be accessible whether it’s a login shell or not. If I DID NOT login, just started a shell, sometimes that’s what I do, or if I modify .bashrc and I want to test my change, I run source ~/.bashrc, then examine the functions, alias definitions and contents of my current environment; all of these are possible methods and they provide a great deal of flexibility; sometimes you may just want a light subprocess that does not have a bunch of aliases, functions, environment variables, etc. and other times you want everything; with this design, you have the choice to include or exclude them, depending on what you are running; a lean function or a full-fledged interactive environment.

                I hope this adds to the conversation and discussion without introducing too much confusion; if confused, we can either discus it more or simply ignore these comments if they are irrelevant to what interests you.

                --
                Brian Masinick

                #129059
                Member
                GeordieProgrammer

                  Been a manic week but – new power supply unit on the way now from EBay on economy delivery – should get by 26th January.
                  So I’ll hopefully be able to have another go with the laptop in a couple of weeks and eventually post what worked for me (as mentioned there is more than one way to do it).
                  Believe it or not – this will be the third power supply for that laptop – original and replacement have both failed.

                  #130045
                  Member
                  GeordieProgrammer

                    Got the new power pack.

                    This command alone (like one of the earlier suggestions) seems to get a functioning JDK:

                    sudo apt install openjdk-17-jdk openjdk-17-jre

                    Haven’t needed to make any changes to $PATH for the system to ‘know’ where the JDK is and to successfully run javac and java commands.

                    #130148
                    Member
                    marcelocripe

                      Hello GeordieProgrammer.

                      Welcome to antiX Linux and the Forum.

                      I don’t know how to write in English and I send my texts translated by the internet translator. I hope you can understand everything. If your native language is not English, please translate my original Brazilian Portuguese text directly into your language with the help of internet translators and you will get a much better result.

                      Please read my real welcome in the Welcome to antiX Linux and the forum (antiX 23) and Welcome to antiX Linux and the forum (antiX 19, 21 and 22) thread.

                      marcelocripe
                      (Original text in Brazilian Portuguese language)

                      – – – – –

                      Olá, GeordieProgrammer.

                      Seja bem-vindo(a) ao antiX Linux e ao fórum.

                      Eu não sei escrever em idioma Inglês e envio os meus textos traduzidos pelo tradutor da internet. Eu espero que você consiga compreender tudo. Se o seu idioma nativo não for o Inglês, por favor, traduza o meu texto original em Português no Brasil diretamente para o seu idioma com a ajuda dos tradutores da internet que você obterá um resultado muito melhor.
                      Por favor, leia a minha verdadeira boas-vindas no tópico Seja bem-vindo (a) ao antiX Linux e ao fórum (antiX 23) e Seja bem-vindo (a) ao antiX Linux e ao fórum (antiX 19, 21 e 22).

                      marcelocripe
                      (Texto original em idioma Português do Brasil)

                      #130162
                      Member
                      techore

                        Haven’t needed to make any changes to $PATH for the system to ‘know’ where the JDK is and to successfully run javac and java commands.

                        This is expected since you used a package for installation and the package maintainer did the work for you. Without reviewing the source package, I cannot *know* this is true, but is very common practice to create pre and post-install scripts as part of the package.

                        Glad you got it working.

                      Viewing 10 posts - 1 through 10 (of 10 total)
                      • You must be logged in to reply to this topic.