Java

99K

Solutions

33K

Contributors

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

Share tech news, updates, or what's on your mind.

Sign up to Post

If you care to read the Oracle advertising:  "Java runs everything"  

So today, I updated to Java 8 Build 171 and instead of the screen that says "Let me check your Java install", there is a different screen"  "Read the roadmap".  

Roadmap:  By the end of next year, businesses will have to license Java (means pay) to use it. By the end of the year after, consumers MAY have to pay to use Java (at least that is how I interpreted it)

0
LVL 28

Expert Comment

by:dpearson
My reading is that they are discontinuing new public releases of Java 8.  They just recommend that you move up to the newest JDK (Java 9+).

If you want bug fixes for Java 8 (after they have stopped releasing them publicly) you'd need a premium support contract.  This seems like a very rare situation - e.g. somebody who can't move up to the newest version, perhaps because they have a massive install base for an existing product, and they still are very concerned about getting new fixes.  Something like the US Dept. of Education.  Wouldn't seem to effect most users, which would either just move up the newer SDK or are happy enough with the last public version of JDK 8.

So seems like pretty normal "end of life" stuff from my reading of that.
0
LVL 103

Author Comment

by:John
I found a better link (Update Java on another machine just now)

www.java.com/en/download/release_notice.jsp

Quote "Public Updates for Oracle Java SE 8 released after January 2019 will not be available for businesses, commercial, or production use without a commercial license"  which I interpreted as "must pay for Java"

Quote "Public updates for Oracle Java SE 8 will remain available for personal use through at least the end of 2020"

I think Oracle wants money from us.
0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

2
LVL 11

Expert Comment

by:Brandon Lyon
Yikes. This could get ugly.
0
LVL 4

Expert Comment

by:Christopher Rourke
Consider the following:

The first case was brought in 2010, adjudicated in favor of Google in 2012, then reversed on appeal in favor of Oracle in 2014.
In 2016 a jury determined Google's actions were shielded by fair use which, again, was overturned on appeal in Oracle's favor two years later.

What I see is a court system of tech illiterate lawyers arguing the merits (or lack thereof) of software & open-source copyright/patent law to tech illiterate judges and juries unaware of the extent and ramifications of their rulings. This will likely continue, the back & forth, for another 8 years or until SCOTUS decides to take up copyright and patent cases of this kind. We can only hope we address the application of laws used to protect the invention of the cotton gin being applied to software.

tl;dr: I wouldn't count android as dead just yet
1
Did you know that Android App developers have a high earning potential? Add this skill to your resume to increase your future earnings. 2 days left to enroll!
1
Android App Development is the must-have technology skill for today. 10 days left to enroll in this month's featured course!  
0
Want to add app development to your resume? You can! Just enroll in February’s Course of the Month for hands-on learning.
0
Back by popular demand: The Android App Development Course of the Month will be extended into February! Enroll now to learn how to build Android apps.
0
Last call! Today is the last day to enroll in January's Course of the Month. Don’t miss the opportunity to learn how to build Android apps to enhance your resume and increase your earning potential.
0

Expert Comment

by:Basem Abeido
HI . in topics from cybersecurity and IT management to business practices and

I note the growing interest in this technology:
Is the spread of hardware: As I call the age of the computer: even smart phones have become mobile computer platforms And Other devices also:

, And here Fox News also published in one of her interesting writings about the importance cybersecurity. and i am add words about the cybersecurity
I would also like to add a few words about the importance of this topic :,Basem-Abeido.jpgBasem Abeido
0
Only 10 days left for January’s Course of the Month! Learn how to build and deploy an Android app. Start the new year off right and enroll today!
1
Did you know that Android App developers have a high earning potential? Add this skill to your resume to increase your future earnings. Enroll in January’s Course of the Month today!
0
Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.
0
Get your problem seen by more experts
LVL 12
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

January’s Course of the Month is now available! Enroll to learn how to build Android apps and pad your resume for future career opportunities.
0
Immutable Class Builders
 
The other day I showed 1 way to make a Class #Builder more meaningful, #semantically, leveraging the #programming language's type system. Today, I'm going to address how to make them immutable, its benefits, and its drawbacks.
 
Why?
 
Class Builders typically use mutable architectures where the programming language allows. In #Java we often see the following model:
 
@Immutable  
final Class Person {  
 
public final Name name;  
public final Address address;  
 
Person(final Builder builder) {  
  this.name = builder.name:  
  this.address = builder.getAddress();  
}  
 
}  
   
@Mutable
final class Builder {  
 
public final Name name;
@Nullable private Address address;
 
private Builder(final Name name) {
  this.name = name:  
  this.address = Address.empty();  
}  
 
public static Builder named (final Name name) {  
  return new Builder(name);  
}  
 
public Builder with (@Nullable final Address address) {
  this.address = (null == address) ? Address.empty() : address;
}  
 
public Address getAddress () {
  return (null == this.address) ? Address.empty() : this.address;
}  
 
public Person build () {  
  return new Person(this);
}  
 
}  
 
Whatever Person field is required, we find in the Builder's constructor. In the above example, that's Name.
 
Other fields are optional, and their value is added to a Person instance by using one if the Builder.with() instance methods.
 
Note how the Builder also features a …
0

Author Comment

by:A.E. Veltstra
Thank you, Brian! I'll look into that.
0

Author Comment

by:A.E. Veltstra
Anton Shipilev showed in 2014 that using all final fields and setting them in the class constructor did in fact slow down initialization when using Oracle's HotSpot Java compiler on ARM and PowerPC. I have yet to see whether his recommendations have been committed. https://shipilev.net/blog/2014/all-fields-are-final/
0
Type-safe class builders
 
The Builder design pattern for software architecture has found quite some traction among people who read the design patterns book by the Gang of 4, as well as those who seek a more fluent, clean-code approach. Oddly enough, these 2 approaches conflict. In this article I'll focus on the latter approach.
 
Uses for the Fluent Builder pattern include reduction of nullable constructor parameters of the target class, reduction of the number of constructors of the target class, reduction of the amount of parameters for constructors of the target class, and providing semantically meaningful method names to specify parameter values for the constructors of the target class.
 
And I find that in the latter use, implementations tend to be lacking.
 
For instance, a typical example is shown in Lokesh Gupta's Builder article over on HowToDoInJava. Read it.
 
Using that Builder reads like this (I have altered it slightly):
 
final User lokesh = new User.UserBuilder("Lokesh", "Gupta").mice(1).desk(14).monitors(3).build();
 
All the hallmarks of a fluent API are there, aren't they?
 
Well. Not really.
 
See, its method mice(int) doesn't signal what its effect will be. "Mice" is just a noun. Not a verb. This is common in Java POJO design, but it shouldn't be here. For self-describing code, I also expect that a setter method signals its effect. Something like setMice(int).
 
But what does that number signify? A type? An amount? Something else? Let's …
1
It seems like an entropy daemon like "haveged" (http://www.issihosts.com/haveged/) can significantly reduce Tomcat start up times.  Java uses /dev/random by default to initialize seed generators.  Problem is, if the entropy pool on a machine is depleted, /dev/random will block until enough environment noise has been gathered to generate sufficient entropy. haveged helps keeps the entropy pool filled up.
2
LVL 11

Expert Comment

by:Brandon Lyon
This is another example of why backends can be hard to get right and are more difficult than they seem. There are so many important minor details.
0
Hello
I'm a new to programming and I need help with a problem please.
I'm trying to call a method (addEmployee( with an Array parameter) from the Department class to the Testing Class through the object sales. However, I cannot seem to to this.
The following line:     sales.addEmployee(alex); // This line is underlined red 'Cannot resolve symbol addEmployee'

// TESTING CLASS
public class TestCompany {

    Employee alex = new Employee("Alex Rod", 6);
    Employee linda = new Employee("Linda Berry", 7);
    Employee john = new Employee("John Doe", 3);
    Employee sara = new Employee("Sara Time", 7);
    Employee james = new Employee("James Doe", 4);

    Department sales = new Department("XYZ Sales");
    Department IT = new Department("XYZ IT");

    sales.addEmployee(alex); // This line is underlined red
    sales.addEmployee(linda);
    sales.addEmployee(john);

    IT.addEmployee(sara);
    IT.addEmployee(james);
}

//DEPARTMENT CLASS
public class Department {

    private String deptName;
    private double budget;

    private Employee[] emps = new Employee[5]; //creates 5 boxes of employees (from Employee Class)
    private int counter =0;

   public Department(String deptName){
       this.deptName = deptName;
       this.budget = 50000;
    }

    public void addEmployee(Employee obj){
       emps[counter] = obj;
       counter++;
    }
}


//EMPLOYEE CLASS
public class Employee {
   
    private String empName;
0

Author Comment

by:Kevin Blakely
Duh!!! I forgot to add public static void main !!! Sorry SOLVED
0
LVL 3

Expert Comment

by:Paul Kent
For future reference, you will receive better assistance if you publish your problem as a Question rather than as a Post. (Click the blue "Ask a Question" button above to ask a question.)
1
#TodayILearned: #Gradle for #EclipseIDE is quite stubborn when it comes to adding a JVM container to one's #Java projects.
 
Every time I update the JVM (in this case to 1.8.0_152) I need to tell Eclipse and Gradle which JVM to run, and which JVM to apply to my Java projects. When we tell Gradle to apply the java plug-in to a project, it automatically inserts some random JRE that isn't defined anywhere. It most certainly isn't the SDK that my projects need.
 
To solve this, we can set the Eclipse classpath from the Gradle build script, after we tell Gradle to apply the eclipse plug-in to a project. It looks like this:
 
def sdkName = 'SDK 1.8.0_152'
def sdkContainerPrefix = 'org.eclipse.jdt.launching.JRE_CONTAINER'
def sdkContainer = sdkContainerPrefix +  '/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/' + sdkName

eclipse.classpath.containers sdkContainer

And then Gradle nicely adds TWO (2) JVM containers: the random JRE it defined in some unknown location, plus the SDK we just specified.
 
(Note: the SDK specified above bears the name 'SDK 1.8.0_152'. This is a custom name chosen by me. It is the same as I chose in Eclipse' preferences for Java -> Installed JREs. In my set-up, it is the only JRE I specified, and therefore the default.)
 
To fix this, with Gradle 4.3.1, we get to undo part of what Gradle's java plug-in does. Instead of the above instruction, we do this:
 
project.afterEvaluate {
  project.eclipse.classpath {
    containers.removeAll …
0
#TodayILearned how to get Gradle to deploy my application distributions and their dependencies to target application servers and library repositories.
 
It has been a missing piece in the automation of my deployments. Gradle already generates the application distributions, but the deployment there-of still was a manual affair.
 
My applications usually are grouped in suites. All applications in a suite share the same base library. That gets assembled and deployed first. Both happen via Gradle. For deployment, I use Gradle's uploadArchives task, from its Java-Library plug-in. This is my script:
 
uploadArchives {
  repositories {
    flatDir {
      dirs localLibFolder
    }
    flatDir {
      dirs sourceRepository
    }
    flatDir {
      dirs targetLibFolder
    }
  }
}
 
My script fills in folder paths for the parameters localLibFolder, targetLibFolder, and sourceRepository.
 
The script also uses that targetLibFolder  in my custom task of type Copy, that generates the individual application distributions. Each app will be distributed in a handful of flavors, and they need to know where to find the libraries on which they depend. Those are stored in the targetLibFolder.
 
Next, another custom task of type Copy depends on my custom task generateDistribution, and copies the distribution to a target folder on the target app server.
 
Each distribution and deployment gets timestamped, so multiple versions can exist next to each other.
 
The last challenge I …
0
We are almost up to Java 9 and there still seems to be no way of copying streams in Java without putting all the boilerplate. So i still seem to need THIS
Please let me know if i'm wrong
0
LVL 28

Expert Comment

by:rrz
The first thing I wrote with Java 9.
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
@WebServlet("/inOut")
public class InOut extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	    response.setContentType("text/plain");
		request.getInputStream().transferTo(response.getOutputStream());
	}
}

Open in new window

and called it with
<html>
	<body>
        <form action="inOut" method="post">
		    param1:<input type="text" name="p1"/>
			param2:<input type="text" name="p2"/>
            <input type='submit' value='Submit'/>
        </form>
	</body>
</html>

Open in new window

0
LVL 87

Author Comment

by:CEHJ
There are probably other instances of other long overdue boilerplate breakers too, but i can't think of them

Of course with my stream copier, you can decide about the closure of both streams ;)
0
Just saw some advertisement where there was code catching a null pointer exception. Are people really out there catching null pointer exceptions. Seems like poor coding style when you can check if the variable is null before hand. We have also been using Java annotations to mark something as null able or not null. This has been really helpful in making potential null pointers compile time errors. Just a random thought.
2
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

#TodayILearned that sometimes, the #Java #CharBuffer can't give an #array of the #CharSequence it #wrap ped.
 
That happened with a #StringBuilder instance, which implements CharSequence.
 
A CharBuffer's array() method normally returns the char[] array that backs it. But the method will throw an #UnsupportedOperationException if no such array is available. And that is exactly the case I encountered today, when I had it wrap a StringBuilder.
 
So instead, we use CharBuffer.get(dest), in which we define dest as a char buffer of the desired size.
 
In my case:
 
final char[] buffer = new char[input.length()];
CharBuffer.wrap(input).get(buffer);
 
Happy coding!
0
A technology that has been really helpful as a Java developer is the ability to hot swap code using a technology like jRebel. Not having to restart the application server every time I make a change has really sped up development.
1
Last chance! Today is the final day to enroll in courseofmonth-native.JPGJuly’s Course of the Month, which prepares you for HTML5 certification. Premium Members, Team Account members, and Qualified Experts unlock this course for free as part of their membership! Once you enroll, you’ll have 30 days to take the course.
4
Boasting Java's speed.
 
Java suffers the myth that it is slow. Those who perpetuate this myth, seldomnly explain exactly what's slow. Benchmarks that do exist, oppose this myth in some cases, and strengthen it in others.
 
So here's some anecdotal evidence to boast Java's speed.
 
I've been developing a JavaFX-based data-editing GUI, to be used by lay people. Its start up from the IDE (Eclipse) is so fast, that its first screen gets displayed in under 3 seconds.
 
Now, I'm assuming that it'll be a bit slower on a client computer, where the JVM isn't running yet. And those computers might be restricted in memory, slowing down the application over all.
 
I'm also developing and maintaining several tens of data-integration applications, for which I frequently run integration tests.
 
Running on their application server, from starting in Windows Task Scheduler, to the moment where they read and archive their input file, tends to take less 5 to 10 seconds.
 
Running in my copy of their IDE (Eclipse), from starting in JUnit, to the moment they read and archive their input file, tends to take 2 to 5  seconds.
 
A factor in the difference between start-up times between IDE-run or Task-Scheduler-run is, well, the Windows Task Scheduler. My IDE might have a bit more memory to run, but the individual applications get restricted in the same way as they are on the app server. Maybe JUnit performs some wizardry that keeps the compilation "hot"?
 
Yes, I have seen some of …
2
LVL 7

Expert Comment

by:Brian Matis
Good to hear! Personally, I've never learned any Java (the syntax has always just looked really weird to me—but I'm sure part of that is just that I'm only a hobbyist, with only some basic experience in C, ASP, PHP, and Python) but I've certainly heard some of the grumbling of Java's speed. I've always been a bit intrigued to learn some Java, especially given its popularity, and it's nice to hear a positive viewpoint. Thanks for sharing!
0
LVL 55

Author Comment

by:Scott Fell, EE MVE
I don't think I shared it for how to catch a bullshitter, but more for the good points to think about in how we work.  A lot of this may be standard operating procedures in their daily lives and others may not.  

My big takeaway is understanding the problem objectively and asking the right questions before forging ahead,.  What problem is this going to solve, what are the costs (not just $$ but time/people),

Some good points for day to day work process.
3
LVL 11

Expert Comment

by:Jeffrey Dake
I totally agree, there are some good points in there about questions we should ask ourselves before we continue developing. I have seen plenty of "refactors" that made the code more reusable but there were no plans to reuse the code. By the time another developer got the chance to reuse it, the original assumptions were no longer valid and another refactor was needed.

As developers we should always be trying to balance how we solve problems with the benefits of how we solve them.
3
#TodayILearned that #OData presents a problem for #XSLT. The #JSON element named "@odata.context" can't be translated into an #XML element with the same name, using XSLT 2 or 3 as provided in #Java by #Saxonica.
 
The problem is that XSLT uses that @ in XPATH statements to match element attributes, and in other places within curly brackets, like {@attribute}, to copy that attribute's content into the output.
 
The solution is to differentiate between nodes/attributes that do, and ones that don't contain an @-sign,  and either replace() or translate() that into something else.
 
In my case, I use fx:json-to-xml() from XSLT3, implemented by Saxonica, to transform received JSON-formatted data into raw XML. This leads to a map element that contains elements array, boolean, map, null, number, and string. The JSON element names become the XML elelements' "@key" attribute.
 
A 2nd XSL transformation produces the domain-specific XML-format. As stated above, we must take heed with producing the "@odata.context" element. This can occur, a.f.a.i.k., in either a null element or a string element. So, we differ between those with and without an "@" in the key attribute:
 
Without:
<xsl:template match="xf:string[@key][not(contains(@key, '@'))]">
<xsl:element name="{@key}">
<xsl:value-of select="text()" />
</xsl:element>
</xsl:template>
 
With:
<xsl:template match="xf:string[@key][contains(@key, '@')]">
<xsl:variable name="newName"><xsl:value-of select="translate(@key, '@', '')" …
0

Author Comment

by:A.E. Veltstra
Hi, Andrew Leniart. Funny, we have the same first name.
 
Thank you for your concern. I did search before I found a way to solve my problem and published it. As far as the search could tell me, I'm literally the first person to encounter and solve this problem. Hence the publication.
0
LVL 19

Expert Comment

by:Andrew Leniart
My apologies Andrew, I didn't read your entire post carefully enough and took it to be a problem you were still trying to solve. I think the hash tag # at the start threw me off! These new fandangled ways you younger generation have of talking can get confusing for oldies like me! lol..

Cheers :)
1

Java

99K

Solutions

33K

Contributors

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.