-2

I have been using 3rd party libraries to process JSON, but I hear Java has one, and I'd rather use that instead. I made a test class that did nothing but import the package and print hello world, but I got the following error.

JsonTest.java:1: error: package javax.json does not exist
import javax.json.*;
^
1 error

I updated my jdk to the latest version (jdk-8u281 as of Feb 28, 2021) and tried again, but it didn't work. Then after some research, I found out that JSON capabilities ONLY exist in Java EE, not Java SE.

After figuring that out, I went to this link HERE to download the Java EE version, but then I didn't know what to do. I extracted the zip file as instructed, and ended up with a folder called /glassfish5. I didn't know what to do with it, so I just tossed it into the /Java directory containing my other jdks.

I looked up guides and youtube videos, but they all seem to stop after you unzip the file. Some show you how to start the database/domain/whatever, but none really tell you how to get the ability to use Java EE (and thus, the JSON functionality contained within it).

And what's even more confusing is that, according to the website, I definitely downloaded Java EE, but why is it giving me a folder called /glassfish5? Is glassfish5 the new Java EE? How do I move forward from here?

davidalayachew
  • 1,279
  • 1
  • 11
  • 22
  • 1
    You get the Glassfish folder, because that's one of the many implementations of Java EE. Java EE is a specification, not a product in itself. – dunni Feb 28 '21 at 19:41
  • Touche. I guess the wording is really important to follow there. Thank you for the help! – davidalayachew Feb 28 '21 at 19:41
  • 1
    It is indeed important, especially when it comes to packaging and distributing your application. I'm not sure, what license Glassfish itself has, so if you distribute your app, and you include those Jars, make sure that the license allows it. With all the restructurings on Oracles side in the area of their Java SE licenses, i'm not sure if they also changed stuff around Glassfish. – dunni Feb 28 '21 at 19:44
  • All the restructuring around Oracle means I really don't want to fool around with it. But thank you for the advice! It's very valuable. – davidalayachew Mar 01 '21 at 02:43

1 Answers1

0

This is really obtuse, but the jar file containing Java EE is located deep within that /glassfish5 folder.

You can find the Java EE jar file by navigating to {download location}/glassfish5/glassfish/lib/javaee.jar -- After you have this, just add it to your classpath, then you are done.

~

I don't understand why they would do that, but if you click around and just aimlessly wander through your /glassfish5 folder, you will find plenty of other jar files around.

Of course, if you don't want to do that, just go to your /glassfish5 folder, go to /bin, then do ./asadmin start-database (using powershell or gitbash). Around the halfway point, you'll find a list of jar files that might be useful.

------------------ Java Information ------------------
Java Version:    1.8.0_281
Java Vendor:     Oracle Corporation
Java home:       C:\Program Files\Java\jdk1.8.0_281\jre
Java classpath:  C:\Program Files\Java\glassfish5\glassfish\lib\asadmin\cli-optional.jar;
                 C:\Program Files\Java\glassfish5\javadb\lib\derby.jar;
                 C:\Program Files\Java\glassfish5\javadb\lib\derbytools.jar;
                 C:\Program Files\Java\glassfish5\javadb\lib\derbynet.jar;
                 C:\Program Files\Java\glassfish5\javadb\lib\derbyclient.jar
davidalayachew
  • 1,279
  • 1
  • 11
  • 22