Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Installing Java on Linux?

 
Ranch Hand
Posts: 102
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really need to install Java 8 on Linux Mint 20.  I'd prefer update 241, or at least a version that can run anything that was built in that exact version - though I did build the runnable .jar file in Windows.  I was able to find version 261 but I don't know whether that's compatible and I haven't tested it yet so I don't even know if it works (I had to get it from one of the download sites where there's no telling what you get).  Does anyone know where I can get that, and better yet, also how to install and run it in Linux?  I don't know much about Linux.

I can't get it from Oracle because they've made everything proprietary now, and I searched for OpenJDK but I can't seem to actually find any relevant downloads (their web site design is confusing).

And I've found videos about how to install it on Linux but they're really abbreviated and don't explain exactly what to do or what the effect of each command is (I'm new to Linux).

In any case, this is REALLY important to me, and it needs to be able to run Java Swing and JavaFX applications.

Also, I'd like to be able to separate the JRE from the JDK and only install what's necessary (I don't know why they always seem to package them together now, but that's the main reason why I went with version 8 in the first place).

Thanks a lot to anyone who can answer my questions (or even attempts to do so).
 
Rancher
Posts: 214
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this on a Terminal window

If you need the development kit:

Verify:


First command ensures you have all the up-to-date available applications to download
Second command uses apt to install the runtime environment
Third command uses apt to install the development kit

Basically apt is a utility to install/remove applications.

JavaFX may be more work.. I think you need some other downloads for it, but I've never ran it on Linux.
 
Sheriff
Posts: 3203
475
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you specifically want Java 8 JDK, then it should be something like: apt-get install openjdk-8-jdk
 
Marshal
Posts: 70604
287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How long do you think that OpenJDK‑8 package will remain available, if we shall have two LTS (=long term support) versions of Java® newer than Java8 by next September? Remember you can use the ‑source and ‑target options to compile code for an older version. Is the very long support date in Wikipedia correct?
 
Saloon Keeper
Posts: 22634
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Linux you have 2 major Java options.

1. OpenJDK. This actually is already present in most distros and if it doesn't get installed when the OS is installed, then you should be able to trivially install it.

      A. For Debian-like distros (including Ubuntu and Mint), do an "apt update; apt upgrade" to get the system up to date, then use "apt-cache search java" and that should should you available OpenJDK packages (and probably a lot of general Java libraries). Then use apt to install your selected package(s).
      B. For Red Hat like distros (including Fedora and CentOS), you can use "yum/dnf search java" to find Java packages and "yum/dnf install" to install them.

  If you prefer to run something else, such as Gentoo Linux, well, we'll assume you're clever enough to figure out the local equivalent.

2. Oracle Java. Java is available at java.sun.com. All platforms are available in ZIP files, and some also as OS installer packages. The installer stuff is basically the same as the ZIP except that a few amenities will get set four you - and the JDK/JRE shows up in your OS package manager's inventory. Licensing terms apply, some options require fees.

IBM had (still has?) their own JDK, and so did Oracle. Most people prefer one of the ones listed above though.

The JDK is largely written in Java, so historically a copy of the JRE necessarily has been embedded within copies of the JDK. To run general Java apps, however, only the JRE is required, so it's also been released separately. It's smaller than the full JDK+JRE distro and doesn't offer casual users tools that they shouldn't be playing with.
 
Terrance Samson
Ranch Hand
Posts: 102
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Griggs, thanks for the info!

Ron McLeod, would that be any specific update version?  Like I said, I built my program using 241, so anything earlier (or possibly something later even) might not work.

Campbell Ritchie, where exactly is the OpenJDK 8 package?  And the JRE too.  Do you have a link?  Because when I went to the OpenJDK website I couldn't find it there.  I also seem to remember that Amazon has a version of JDK/JRE, don't they?  Does anyone know about that or how to get it?

Tim Holloway, well like I said, I'm using Mint 20, which is Debian.



By the way, the Linux installation that I'm trying to put Java onto does not have access to the internet.  I don't know if that affects anything.
 
Saloon Keeper
Posts: 6625
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
241 or 261 should not matter, they just differ in some bugs fixed. I prefer to get stuff from AdoptOpenJDK rather than the Amazon JDK.
 
Campbell Ritchie
Marshal
Posts: 70604
287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Terrance Samson wrote:. . . where exactly is the OpenJDK 8 package?  And the JRE too

No idea. Some repository or other; I tried various combinations of numbers and jre/jdk in the apt-get instruction Ron showed you and they all seemed to work.

. . . . does not have access to the internet.  I don't know if that affects anything.

Afraid it does. You can download openJDK as a .tar.gz file from the standard download link You can probably get a Java8 JRE but they withdrew the separate JRE for Java11+. Put the .tar.gz onto a USB thumb drive/memory stick and unzip it from there, and update JAVA_HOME as per usual.
Maybe the Java8 downloads were under the old EULA so you can download the Oracle version; I am not sure.
 
Tim Holloway
Saloon Keeper
Posts: 22634
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where to find OpenJDK? Depends on what you want.

As I said, OpenJDK is a standard component of all major Linux distros now, ,and the distros are mirrored all over the world. The "apt-get update" command updates your machine's local list of distro servers to reflect the currenlly-available mirrors (presumably focused on the ones that respond fastest). That helps optimize the package download process. If you go that route, it's no different than installing any other Linux app.

You can also pull pure binaries built by the OpenJDK project and hosted on Oracle's java.net servers. This is not what I'd recommend for most people since I can't guarantee that the archives built and stored there will be as seamlessly integrated into your distro. But you may be able to find newer/experimental builds there if you're brave. Archive-format Java kits are simply unarchived to whatever location you find convenient, since Java has always been designed to run out of a single directory subtree. The Sun/Oracle convention for Red Hat has been /usr/java/jdkversion to allow for central location of multiple JDK installations. But your home directory is OK if you don't intend it for system-wide use.

And then, of course, for the truly dedicated, you can pull OpenJDK source and build it all from scratch. OpenJDK is not stored under git - they use Mecurial, so in addition to the compilter toolchain, you'll need the client program for Mercurual (hg).

As far as licensing goes, I think the Oracle Java (not OpenJDK) is free up to at least Java 11, but beyond that check for license restrictions. OpenJDK, of course, is free by definition.
 
Terrance Samson
Ranch Hand
Posts: 102
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores, well that's good to know.

Campbell Ritchie, then I guess it's good that I downloaded it.  I have a few versions and 32/64 bit just in case.  I got .rpm files (which I don't think will work unless I use Redhat or something, but I'm using Mint), and also .tar.gz (which are like .zip files, right?).  How do I decompress/extract the files from that?  Or should I do it in Windows and then just take those extracted files and put them in Java?  Or can I even do it in Windows?

Tim Holloway, keep in mind that the computer I'll be installing it on has no internet connection.  Everything you're saying seems to imply that I'll be downloading files or lists of files during the installation process, if I understand you correctly (see what Campbell said and what I replied in the line above this one).
 
Sheriff
Posts: 22015
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Terrance Samson wrote:How do I decompress/extract the files from that?  Or should I do it in Windows and then just take those extracted files and put them in Java?  Or can I even do it in Windows?


unpack tar.gz. Don't do this on Windows; while some tools can handle them (7-Zip for instance), any Linux installation should come with tar and gzip and therefore should be able to do it.
 
Terrance Samson
Ranch Hand
Posts: 102
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I looked up the unpack command to see if I could find detailed information, but I just found stuff about tar and gunzip, though it seems to do the trick (theoretically, but I haven't tried it yet).  Anyway, it's some interesting information on unzipping and stuff.  Thanks for the advice.

This might be a stupid question, but isn't there a way to associate these files with a decompression program so that all I have to do is double-click the file and it works like it would in Windows?  I mean, I get why Linux uses all of this command line stuff, because it's essentially an OS for programmers, but is there a reason why everything is done that way?  I mean if there is, then that's fine, but it seems like there are easier ways to do simple and common things like decompressing a file, so it wouldn't need commands to be typed.  Am I right?  EDIT: And for that matter, things like running installers, running text editors to edit configuration files and such, and just doing a lot of stuff like that, at least with the most common default options, could be handled entirely by the GUI, and then I guess if you wanted more advanced options then you could type the commands.
 
Tim Holloway
Saloon Keeper
Posts: 22634
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. I guess life could be more fun if you have no direct Internet connection. I have to assume some sort of indirect connection though, if you have anything more than an install DVD or thumb drive (in whiich case you should find the OpenJDK package there, if not the latest one).

A tar,gz file is what happens when you run a set of files through the tar utility and then uze gzip to compress them.

The Tape Archive (tar) utility is hardly ever used ti make tape files anymore, but it's a serializing utility - designed to take a set of files/directories and reduce them to a single file. It's similar to ZIP, then, except that ZIP attempts to compress data unless told not to and tar has no compression capabilities. The gzip (GNU ZIP) utility, on the other hand takes a file and compresses/decompresses it (gzip/gunzip). Unlike ZIP, it takes exactly one and only one file (or more accurately data stream). Why are these functions separate instead of all-in-one like in ZIP? Well, for one thing, I think that tar was being used before compression became common, for another, it kept progams small and simple (the original Unix philosophy prefers chaining simple programs together instead of making one big program). And finally, gzip uses Lempel-Zev compression, which was developed more recently. In older times, it was common for Unix to use a utility called compress, but the algorithm used with compress is less powerful than Lempel-Zev.

In modern Linux, yes, you can explode a compressed tarball with a single command. Use the tar options "tvzf", where "t" means "extract", "v" is for "verbose" (optional), "z" for compress/decompress amd "f" indicates that the name of the tarball file will be next on the command line.

Both ".tar.gz" and ".tgz" are used to indicate compressed tarballs. It's mostly preference. Other options include the bzip utility, which was once used as a more efficient alternative to ZIP (file extension is ".bz2"), but tarballs are the standard.

And yes, if you wanted to, you could double-click on a GUI desktop icon and browse, expand or edit tgz files if your desktop has a GUI explorer such as File Roller mapped to the file extension in question. Although if you intend to unpack the file and use it, you might as well be at a command prompt, because you'll need it for the next steps.
 
Terrance Samson
Ranch Hand
Posts: 102
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway, I think Lempel-Ziv is pretty old, and even LZW for that matter, so tar must be really old, but anyway, that's all very interesting.  I guess tar is just sort of a file bundler.  And I'll use the tar and gunzip commands to explode compressed hairballs... er, tarballs.  But to what "next steps" do you refer at the bottom?  You mean to use whatever file I've decompressed or to install it?  Well, an installer could have a double-click function too, but actually, I've found several different ways to install Java, all of which use the command line, but I'm not sure which is best.  Here are the notes that I've taken, if anyone can make sense of them:



try java -version first to see what the version is by default!





or




jdk1.8.0_241 (I think I got 261 or something)

??? (guy in video just pasted that!)
file seems to be jdk-8u261-linux-x64.tar.gz (maybe)

type a number and enter

I read somewhere else:




another video by the same guy who didn't explain what he was doing said:



some of these commands must be set to file names or something I guess, so they may vary




should say:
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
or something like that





that installs java 8 runtime and "some other useful stuff" (I don't know what)
 
Campbell Ritchie
Marshal
Posts: 70604
287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gone back to your post and added code tags with the bash option (see the dropdown list), so we can actually see what the instructions you used were, and preceded the comments with #.

Terrance Samson wrote:. . . How do I decompress/extract the files from that? . . . .

Follow the link Rob posted. Also consider trying the 7‑zip program; it occupies <1MB of download and works really well, but most Linux installations include apps to handle 7z files as a default. Assuming you have the .tar.gz in Downloads, try this sort of thing.Depending on the permissions of your locations, you may need sudo too. You probably need to open the terminal anew to see the new version numbers (lines 4‑5).

Please give us more details of the video you found. The lesson from what you showed is that there is nothing so complicated that somebody can't make it more complicated still. If you have extracted the file correctly, you only need to update JAVA_HOME to use it. Please update JAVA_HOME, which is used by NetBeans and some other programs, and don't update PATH. The PATH you got from the video isn't updated correctly:-
  • 1: You are updating the same thing twice, which provides two opportunities to make mistakes.
  • 2: The new PATH should go at the beginning.
  • The v option makes the extraction process print the location so you can easily copy the name of the directoryI would be wary of exporting JAVA_HOME to /etc/profile.d/xxx, in case your profile file gradually enlarges and your PATH gets longer and longer and longer; I prefer .bashrc because you can update JAVA_HOME whenever you install a new version. If you use that format for PATH, the JAVA_HOME variable is read into the PATH whenever you execute .bashrc, i.e. whenever you open a terminal. You therefore don't need to update PATH every time.
    You only use a file name if you have downloaded a file to extract.
    You will find a bit about webupd8team in this FAQ; I thought that trick only worked on Ubuntu.
    The abbreviation .tar means, “tape archive,” which means it dates from the days when computers had 18″‑wide tape reels turning above them, like on Star Trek. Yes, it does bundle files into tarbabies “tarballs”.
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well thanks a lot for the info!  I'll do it your way.  I only have a few questions/answers about the code that you wrote:

    - Keep in mind that I doubt I'll need to write Java code in this Linux installation - in fact, I really just need the JRE rather than the JDK (though I guess the JDK wouldn't hurt, but I really just need to run Java Swing and JavaFX JAR files).  You mentioned NetBeans, and if I'm not mistaken, that's an IDE like Eclipse, right?  So then would I need to install that just to run Java programs, or only to make them?

    - I've seen the zxvf written with the "-" before it and without.  What's the difference or does it matter?  And does the order of the letters matter?  Because I've also seen them in various orders.

    - I searched for kate and all I found was a bunch of information about dates, but I guess I'll just use whatever text editor I have, though are you then implying that I should open the file called "~/.bashrc" and then find where it mentions "JAVA_HOME", manually change its value (presumably after a "=" or something) and then save the file?  And that's what you've listed below in the other code lines?

    - I didn't keep a link to the video.  I find a bunch of short videos of how to do this or that, but this one had a guy with a very thick accent who was a bit hard to understand, but he also summarized everything to the point of only saying that he was doing it without saying why or what specific effect it would have (the whole video was about 2 minutes long and he just copied and pasted a few lines into the terminal).

    - My notes are saying to update twice?  Well keep in mind that all of the stuff that I posted just then was several different groups of commands that I got from different sources, rather than just one big group of commands to do in order, and my point was that they all do it different ways, so if each do some things redundantly of each other then that's to be expected.

    - When you say the new PATH should go at the beginning, I don't know what you mean.  Do you mean the beginning of the line of text?  Like where it says "PATH=..."?  Because I thought that's how I already had it.  Or do you mean it should be set in the first line of text?  Because you're setting JAVA_HOME just before that.  Or do you mean to put both of those lines as the first lines of the file?

    - If I do something like PATH=$PATH... does that append the path variable onto itself, making it longer each time?  If so, that would definitely be an error!

    Well, I guess it was a few more questions/comments than I had originally thought it would be, but I'm a thorough person, because I'd rather be certain that I'm doing things the right way then to do one little thing wrong and not be able to figure out what that little thing is!
     
    Campbell Ritchie
    Marshal
    Posts: 70604
    287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Terrance Samson wrote:. . . NetBeans . . . an IDE like Eclipse . . . So then would I need to install that just to run Java programs . . .

    Yes . . . No

    - I've seen the zxvf written with the "-" before it and without.  . . .

    Don't know. Use man tar and see what it tells you.

    use whatever text editor I have . . .

    Yes

    open the file called "~/.bashrc" and then find where it mentions "JAVA_HOME" . . .

    It probably won't have JAVA_HOME and PATH in at all; you will have to add them both. If you don't use NetBeans, you can probably telescope the two into export PATH=... and omit JAVA_HOME.

    . . . update twice? . . .

    You can't do any harm with update, but inflating the .tar.gz doesn't require update at all.

    . . . Do you mean the beginning of the line of text? . . .

    It means the new entry coems first, as I wrote it. It means that directory is searched first when looking for java, javac, etc. Otherwise there is a risk of finding multiple installations with mutually conflicting version numbers.

    . . . PATH=$PATH... does that append the path variable . . .

    It adds the new entry to the previously set PATH for the purposes of the current terminal.
    Don't worry too much about too long a PATH. The runtime stops searching as soon as it finds its target. You can however get problems if you have multiple copies of related commands with different versions.
     
    Tim Holloway
    Saloon Keeper
    Posts: 22634
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Let me add a few odds and ends. Since I only have limited screen space, it's hard to keep track of all the questions and suggestions, but I'll address the ones that I found most noteworthy.

    7zip is an archiver like ZIP, but the ZIP standard doesn't support files larger than 4GB and 7zip does. it's a completely different program than the gzip and zip utility programs and since installation packages (fortunately! so far!) don't require large file support, tarballs remain the accepted standard. Except I think in Slackware, where bzip was popular when I worked there. So many standards! So I wouldn't mess with 7zip here. It's almost never in the standard OS install, so you'd have to install it manually and that's just one more step for no immediate benefit. Actually, zip/unzip are themselves often not in the basic OS install, although gzip and tar usually are.

    About the dash on the command line. There is no absolute standard on command line option syntax, although conventionally a dash is used. Except on the ps command, where it's disdained. And on dd, which ahas its own charming syntax form. And... The original Unix command line format called for option switche flags to be single letters and/or digits and the convention has been that you can stack them all behind a single switch indicator. That is "tar -t -v -z -f filename.tgz " is also valid as "tar -tvzf filename.tgz". The order of the switch flags is mostly arbitrary except for flags that have operands. That is "tar tvfz filename.tgz" would be mis-interpreted, since the filename must immediately follow the "f" flag. And on some utilities, "tar -tvzffilename.tgz" will work. Haven't checked tar on that one. It's too hard to read and too easy to screw up.


    You don't need a JDK to run apps, no, much less an IDE like NetBeans.

    Regarding Campell's recommendations, setting options in /etc/profile.d would be appropriate for default systemwide settings, like for multi-user timeshare servers  but I never use it for Java myself. I use .bashrc settings:


    Yes, expanding PATH like that does make it longer, but it's only done when the environment is constructed (when I login) so it's not like it gets longer and longer forever.

    JAVA_HOME, incidentally, is not an official part of the Java spec. but a lot of Java apps look for and use it. The Eclipse IDE, however, does not, for example. A given command shell instance can (re)define JAVA_HOME and it will not affect any other command shell's environment. Likewise, redefining JAVA_HOME will not update the PATH, since $JAVA_HOME/bin:$PATH is evaluated at the time it is set and not dynamically. If you want a different Java bin in your PATH, you have to re-define the command shell's PATH.

     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks to both of you for some very useful information.  I think it may make things a lot easier for me.  For one thing, it looks like I won't need to install an IDE or perhaps even a JDK (I looked and it seems to have version 11 installed by default, but I don't know if that will run programs compiled using version 8 or not - I'll try and see).

    Campbell Ritchie, I think I follow pretty much everything that you're saying, except I'm not sure what you mean by "you can probably telescope the two into export PATH=...", but otherwise I'm pretty sure it makes sense.

    Tim Holloway, thanks for the explanation about the command line parameter conventions.  I think putting the two together without a space is BAD and I can't imagine why or how it would even allow that!  But thanks for all the advice.

    I may yet develop using Java on a Linux partition, so it's good to know how to install all of this stuff.  But for now, I'm just going to try to run the JAR file, and if it doesn't work, I'll install JDK/JRE version 8 and see if it works then.
     
    Campbell Ritchie
    Marshal
    Posts: 70604
    287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Terrance Samson wrote:. . . you can probably telescope the two into export PATH=...", . . .

    It means rather than writing two lines as I showed earlier, you write export PATH=/my/path/to/java/jdk8_261/bin:$PATH or similar.

    I'm pretty sure it makes sense. . . .

    First time for everything; nobody else thinks what I write makes sense

    I may yet develop using Java on a Linux partition . . .

    It should look just like Java® developed on a Windows® partition.

    And, ...that's a pleasure.
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for clarifying that line.  And I've heard all about Java working the same in all circumstances (I guess as long as you're not relying on DLLs compiled in C or something), but I don't think I've ever seen it before, so that will be interesting.  Anyway, thanks again!
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sure, I agree.  It just gradually evolved into the other topic because that's where the conversation lead and the type of issues that I was having (for anyone who thinks I've lost my mind, some of the posts were moved to a new topic, and this post is in reference to that fact, about which the previous post will supposedly soon be removed so that this wouldn't make sense out of context).
     
    Tim Holloway
    Saloon Keeper
    Posts: 22634
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Terrance Samson wrote:Thanks for clarifying that line.  And I've heard all about Java working the same in all circumstances (I guess as long as you're not relying on DLLs compiled in C or something), but I don't think I've ever seen it before, so that will be interesting.  Anyway, thanks again!



    Java's biggest claim to fame is indeed "write-once/run-anywhere". Avoiding DLLs and other native-code classes is essential to make that happen, yes, but there are other considerations.

    For example the filename paths and locations vary with the OS. That's something that can be reduced, though, since Java accepts a "universal" file path format based on Unix (so you can code "C:\\Program Files\\jre-1.23.4\\bin\\java.exe" as "C:/Program Files/jre-1.23.4/bin/java.exe", for example, and break up the path-construction logic so as to allow the OS-dependent parts to be isolated and made reconfigurable. For example:


    Ports to Linux just by changing the values of javaExe and javaBinDir - which can be read from a properties file or supplied as command-line options. Do note that filenames are case-sensitive in Unix and Linux, so don't be sloppy there. Even in Windows Java will potentially get annoyed if you're not consistent with upper/lower case in filenames and paths.
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yeah, the stuff about the file paths occurred to me, but fortunately, the programs that I'm trying to use don't have any hard-coded paths.  They allow users to open files, but it just gives a window for choosing them.  As for the default path, I tried setting it to the current path (where the Java program resides), and if for any reason an exception gets thrown, then I set it to null (in Windows it puts it in the "My Computer" window and just shows the drives, so in Linux I guess it will just show the contents of opening the "Computer" icon, whatever directory that represents).
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I changed to version 8 and now Swing and FX both seem to work great!  I haven't tested them with any complicated applications, but if they open and do what they're supposed to then it will probably work with all version 8 applications.
     
    Campbell Ritchie
    Marshal
    Posts: 70604
    287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Careful about FX; it was moved out of the standard installation after Java8.
     
    Terrance Samson
    Ranch Hand
    Posts: 102
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I thought that was version 11?  No matter, I'm using version 8 so it works.  Why isn't it included, anymore, by the way?  Isn't it supposed to be the latest and greatest GUI for Java, as a newer alternative to Swing?
     
    Campbell Ritchie
    Marshal
    Posts: 70604
    287
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I can't remember when FX was moved, but it was definitely a standard feature of Java8. You can download it somewhere else now.
     
    I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
    reply
      Bookmark Topic Watch Topic
    • New Topic