LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-29-2017, 04:49 PM   #1
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 468

Rep: Reputation: Disabled
My new slackware - programming experience


I started using Slackware in December of 2016, so I still consider myself as a Slack newbie. I came over from Gentoo. I got really really tired of trying to get help and always being told that I am not smart enough to be using Gentoo. It seems that unlike most Gentoo users, I do not know everything. I have been trying for the last two months to turn my back on the Gentoo way of thinking in order to learn the Slack way of thinking. I am wondering how a Slack user would do what I am currently attempting.

About twenty years ago I entered college and acquired an associate's degree in computer science. Shortly after I got my degree, I was declared disabled, so I never actually used my degree for a job of any sort. Mostly, I was a hobbyist programmer. Now, I find myself nearing forty years of age and not knowing how to do much of anything at all beyond dressing myself and basic hygiene.

Today, I am attempting to start learning Java. Slackware does not install Java by default. The tutorial I am using says to run javac/java. I don't have those. I have gcc. I created a directory called "Java" and tried the first program in the tutorial. I understand all the concepts in the program, and am using it as a test to make sure that my tools work correctly. I entered the following program:

Code:
michael@caitlyn java $ cat MyFirstJavaProgram.java 
public class MyFirstJavaProgram
{
   /*This is my first Java program (not really)
    * This will print "Hello World" as the output (Duh!)
    */
   public static void main (String [] args)
   {
      System.out.println("Hello world!");
   }
}
I ran gcc.

Code:
michael@caitlyn java $ gcc MyFirstJavaProgram.java 
no classpath specified
Then I googled and found that I needed to be running gcj instead.
Code:
michael@caitlyn java $ gcj MyFirstJavaProgram.java 
/usr/lib64/gcc/x86_64-slackware-linux/5.4.0/../../../../lib64/crt1.o: In function `_start':
/glibc-tmp-121049354ebdd5d6a32918f2f5c54ab5/glibc-2.24/csu/../sysdeps/x86_64/start.S:110: undefined reference to `main'
collect2: error: ld returned 1 exit status
I am wondering: Should I attempt to install real java? Is there a Slack-ier way I should be looking at this problem?

NOTE: I thought that I remembered this particular error from my early days with Linux (early 2000s) and that it had something to do with naming the directory 'java', so I renamed it to 'java-homework', but the error about main not being defined still remains...
 
Old 01-29-2017, 05:14 PM   #2
Gerard Lally
Senior Member
 
Registered: Sep 2009
Location: Leinster, IE
Distribution: Slackware, NetBSD
Posts: 2,177

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Hi
the information you need can be found here. In short, for licensing reasons Slackware can't distribute Java, but it is easy to install. To develop Java applications you need the JDK (developers' kit), which includes the JRE (runtime).
 
Old 01-29-2017, 05:16 PM   #3
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
maschelsea --

What you probably need is a jdk.

And your timing couldn't be better.

Just today, Alien Bob released Openjdk (Java8) updated with January fixes

And there is also a Java.SlackBuild in the Slackware extras/ directory of you would rather go with the Oracle jdk.

Maybe dig around a bit on Eric's Site ?

HTH.

-- kjh
 
1 members found this post helpful.
Old 01-29-2017, 08:35 PM   #4
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 468

Original Poster
Rep: Reputation: Disabled
kjhambrick: I clicked your link, downloaded openjdk-8u121_b13-x86_64-1alien.txz and ran installpkg on it, but when I go back to my terminal tab that I was working through the tutorial in, and issued 'javac', it didn't work.
Code:
michael@caitlyn java-homework $ javac MyFirstJavaProgram.java 
bash: javac: command not found
michael@caitlyn java-homework $ which javac
which: no javac in (/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib64/kde4/libexec:/usr/lib64/qt/bin:/usr/share/texmf/bin:/home/michael/.bin)
Any idea why?
 
Old 01-29-2017, 08:47 PM   #5
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 928

Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Quote:
Originally Posted by maschelsea View Post
Code:
michael@caitlyn java-homework $ which javac
which: no javac in (/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib64/kde4/libexec:/usr/lib64/qt/bin:/usr/share/texmf/bin:/home/michael/.bin)
Any idea why?
Just maybe logout and login to put java in the PATH.
 
1 members found this post helpful.
Old 01-29-2017, 09:00 PM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
When jdk is installed, it adds a new script to /etc/profile.d/ that adds the java locations (in the openjdk you installed, it is called openjdk.sh). You can log out and re-login to have the script run automatically, or you could just run the script manually yourself.

Code:
/etc/profile.d/openjdk.sh
This will be run automatically every time you log in, so the only time you'd need to run it manually is right after your first installation, and only if you don't want to log out and then log back in
 
1 members found this post helpful.
Old 01-29-2017, 10:22 PM   #7
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 468

Original Poster
Rep: Reputation: Disabled
Code:
michael@caitlyn java-homework $ /etc/profile.d/openjdk.sh
michael@caitlyn java-homework $ javac MyFirstJavaProgram.java 
bash: javac: command not found
michael@caitlyn java-homework $
Also, I have OpenJDK 1.8.0 Monitoring and Management Console and OpenJDK-1.8.0 Policy Manager on my Development menu in xfce now, but they don't seem to point to anything that exists (they error when I try to run them)
 
Old 01-29-2017, 11:16 PM   #8
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
I'm running an older version of jdk, but I imagine it hasn't moved. It should be in:

Code:
/usr/lib64/java/bin/javac
That directory should be covered with the $JAVA_HOME/bin in the PATH variable specified in the openjdk.sh

Code:
#!/bin/sh
export JAVA_HOME=/usr/lib64/java
export MANPATH="${MANPATH}:${JAVA_HOME}/man"
export PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
You can check your PATH variable, which should look something like this:

Code:
jbhansen@craven-moorhead:~$ echo $PATH
/home/jbhansen/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games:.:/usr/lib64/kde4/libexec:/usr/lib64/java/bin:/usr/lib64/java/jre/bin:/usr/lib64/qt/bin:/usr/share/texmf/bin
If you want to quickly make it available, you can run this command (if you're running 32bit, remove the "64" from lib64):

Code:
PATH="${PATH}:/usr/lib64/java/bin:/usr/lib64/java/jre/bin
 
Old 01-30-2017, 01:43 AM   #9
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Quote:
Originally Posted by maschelsea View Post
Code:
michael@caitlyn java-homework $ /etc/profile.d/openjdk.sh
michael@caitlyn java-homework $ javac MyFirstJavaProgram.java 
bash: javac: command not found
michael@caitlyn java-homework $
Also, I have OpenJDK 1.8.0 Monitoring and Management Console and OpenJDK-1.8.0 Policy Manager on my Development menu in xfce now, but they don't seem to point to anything that exists (they error when I try to run them)
maschelsea --

bash didn't complain when you typed: /etc/profile.d/openjdk.sh

This means the file exists.

However, simply executing that login script doesn't affect your current bash session.

It needs to be 'sourced' into your environment so bash can find the java tools.

As others said, you'll need to log off and log on again, or this:

Code:
source /etc/profile.d/openjdk.sh
-or-

Code:
. /etc/profile.d/openjdk.sh    # that is dot-then-space-then /etc/profile.d/openjdk.sh
Try again ?

HTH

p.s. I didn't see gezley's post #2 ( above ) but please check the link in his post -- lots of good info there, including a good explanation as to why javac does not work for you yet.

-- kjh

Last edited by kjhambrick; 01-30-2017 at 02:07 AM. Reason: add p.s. to gezley's post
 
1 members found this post helpful.
Old 01-30-2017, 09:59 AM   #10
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 468

Original Poster
Rep: Reputation: Disabled
It works now. Thank you!!!!
 
Old 01-30-2017, 11:37 AM   #11
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by kjhambrick View Post
However, simply executing that login script doesn't affect your current bash session.

It needs to be 'sourced' into your environment so bash can find the java tools.

As others said, you'll need to log off and log on again, or this:

Code:
source /etc/profile.d/openjdk.sh
-or-

Code:
. /etc/profile.d/openjdk.sh    # that is dot-then-space-then /etc/profile.d/openjdk.sh
Crap, good catch. I was thinking it needed to be sourced, but when I looked at it, it looked like it would just set the variables and export them. Guess I have more reading to do with bash on how variables carry over when executed vs sourced.
 
Old 01-30-2017, 03:04 PM   #12
maschelsea
Member
 
Registered: Dec 2016
Distribution: Slackware 64bit 14.2
Posts: 468

Original Poster
Rep: Reputation: Disabled
I thought all the source command did was executed the supplied script. I guess not. Is the '.' as in ". /etc/profile the same as 'source'?
 
Old 01-30-2017, 04:06 PM   #13
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by maschelsea View Post
I thought all the source command did was executed the supplied script. I guess not. Is the '.' as in ". /etc/profile the same as 'source'?
After reading this source vs executing (running openjdk.sh without sourcing it) makes a lot more sense.

In short (probably so simplistic it may not be 100% accurate, but "good enough" ), source applies the commands to your current shell, where executing the script will apply them to a subshell, which is closed when the script closes.

And yes, source openjdk.sh and . openjdk.sh are the same thing.
 
Old 01-30-2017, 05:03 PM   #14
elsheepo
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Slackware
Posts: 90

Rep: Reputation: 20
Installing jdk on slackware/slackware64, via sbopkg

Installing jdk on slackware/slackware64, via sbopkg was fairly simple for me. Just another way to solve it, with jdk. It of course assumes you have sbopkg installed.

1) Acquire jdk source tarball.

a) Proceed to http://www.oracle.com/technetwork/ja...s-2133151.html
using your prefered web-browser.
b) Accept the Oracle Binary Code License Agreement for Java SE.
c) Download either, jdk*i586.tar.gz for slackware or, jdk*x64.tar.gz for slackware64.

2) Move the tarball to the sbopkg source directory.

a) Log in as root.
Code:
$ su -
b) Move tarball (assuming username:foo & web-browsers download directory:~/Downloads).
Code:
# mv /home/foo/Downloads/jdk*.tar.gz /var/cache/sbopkg
3) Sync sbopkg with the remote repository.

Code:
# sbopkg -r
4) Build and Install jdk.

Code:
# sbopkg -i jdk
 
Old 02-02-2017, 01:43 AM   #15
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
You may want to install NetBeans while you are at it. Slackbuilds has it.

Depending how much java you intend to do (I've been programming in Java since 2000), I'd recommend NetBeans or IntelliJ. I absolutely detest/hate the IntelliJ user interface. If you intend to do anything in Grails (which I don't recommend), IntelliJ handles grails/groovy code better than NetBeans by far.

If you intend to use Spring Boot (which I do recommend, since companies like that knowledge), then NetBeans is still OK but IntelliJ is better at resolving Spring Beans. (If you don't know what a Spring Bean is, don't worry about it.)

If it isn't Grails, I personally use NetBeans. If it is Grails, NetBeans is effectively useless; use IntelliJ in that case.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Dart: a New Web Programming Experience LXer Syndicated Linux News 0 05-08-2013 02:50 AM
Be a DBA w/ No Programming Experience? carlosinfl General 14 05-02-2012 06:23 AM
I have no coding or programming experience of any sort. Is Linux a good idea for me? taloncrewchief Linux - Newbie 13 11-26-2009 11:34 PM
LXer: Get Hands-On Experience Programming Blue Gene LXer Syndicated Linux News 0 07-18-2006 06:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration