East of Java has fair trade goods and items

It was a big adjustment when Amber Kennedy made the move from Haida Gwaii to Port McNeill.

“My kids went from a school of 28 people to a class of 28,” said Kennedy.

The family moved to Port McNeill when Kennedy’s husband found work on the North Island.

“But its still a nice small town feel here,” she added.

Kennedy has since put down roots in the community, owning East of Java at 584 Broughton Blvd in Port McNeill for going on six years.

East of Java is a quirky gift shop with a long history in Port McNeill, as it was previously owned by Colleen Kostyshyn for around twenty years.

“I knew that I wanted to be self employed and I just fell in love with the store,” said Kennedy.

“I was talking to Colleen one day and found out she wanted to retire and it just went from there.”

Kennedy said the biggest change she made singing owning the store was moving to a new location.

She added about 1000 square feet when she moved from the previous location by the drugstore to her current storefront in Pioneer Mall, allowing her to store more items. “It’s a better location for exposure,” said Kennedy.

“I love everything in the store, I have to love it to bring it in – quality is the most important thing to me.”

She added one of her biggest priorities is that anything she imports has been fairly traded and ethically produced.

East of Java stocks a wide variety of unique gifts, baby items, clothes, oils, local art and so much more.

“We have functional items for the family and not just giftware, so its easy to find what you’re looking for,” said Kennedy.

“We have a heavy tourist season here but I rely on local customers too because the store is open all year round.”

Kennedy hopes people who have never been in the store before, stop by to check it out.

“You don’t know what’s here until you come and have a look,” she laughed.

[“Source-northislandgazette”]

Trio of Starbucks Rejects Delivers Java Fix to New Haven

IMG_1186.jpg

There is something wonderfully freeing about working in a food truck. The job seems to appeal to a certain free spirit, that individual who can’t quite fit into an office or even a kitchen in a restaurant. In a food truck, you are the king of your own domain. No bosses, no suit, just a view of whatever corner of the world you choose through a small window as waves of people come by to sample your wares. You listen to whatever music you choose, and approach the job whichever way you want.

The three New Haven 20-somethings who own and operate the Jitter Bus coffee truck in the Elm City — Dan Barletta, Paul Crosby and Andrew Mesiouris — are not huge fans of bosses. Having met as teenagers in West Haven, all three have been fired from Starbucks at one time or another. “You’re not cut out for this job,” Barletta says they told him when they let him go.

Well, joke’s on them. Now Barletta makes a living with his friends, working for themselves and each other, selling coffee on their own terms. Crosby, who has SINK and SWIM tattooed on the knuckles on his respective hands and was fired from a Starbucks in West Haven, says this has been the idea for him from the start. “It’s been my plan since I was in like fifth or sixth grade. It was a tattoo shop when I was young, but as I fell out of that, I grew into this,” he says.

Aesthetically, the Jitter Bus looks like what the Addams Family would come up with if they quit television and became do-it-yourself punks and tattoo artists. The old school bus is painted black with white designs hand-painted on. The Jitter Bus’ goth color scheme stands out amid the proliferation of brightly painted food trucks that populate our cities. Its one-year anniversary party was held back in March at Keys on Kites Tattoo & Gallery in New Haven’s Westville section, where they had a music show and raffled off a free tattoo.

The do-it-yourself attitude is not a hollow one. The guys in the Jitter Bus have built most of the mobile cafe’s components. Water tanks, counter tops, shelves, bus mechanics, even the swivel tray that holds the iPad cash register: all were built and designed by the three owner-operators.

On a blisteringly hot June day at their usual spot at the corner of Hillhouse Avenue and Grove Street, the boys on the bus are serving up hundreds of coffees ($2-$2.50), cappuccinos ($3.25-$3.75), cortados ($3.25), mochas ($4.25-$5), espressos ($2), chai ($3.50-$4) and the iced versions of all of them ($3-$5). Extra espresso shots can be added for 75 cents, and flavor shots of vanilla, hazelnut, caramel and coconut for 50 cents.

They get all their coffee from Connecticut, mostly from the Canton micro-operation Giv Coffee, and its excellent espresso blend Star Breather, sourced from Peru and Brazil with notes of dark chocolate, raisin and almond. Newington’s Saccuzzo Coffee Co. also provides beans, while pastries come from New Haven’s Whole G bakery and milk and cream from Connecticut-sourced Farmer’s Cow.

Despite the heat, there is a steady stream of people coming up for their usual fix. “We’re pretty much legal drug dealers,” says Crosby. “We sell it on the corner and everything,” Barletta adds after a laugh. The hundreds or even thousands of hole-punched loyalty cards oozing from every crack in the truck testify to the popularity of the truck and the regularity with which its patrons return. (While Hillhouse and Grove is their usual corner, the Jitter Bus is available for booking for events and festivals.)

A digital stroll through the Jitter Bus’ social media (follow The Jitter Bus on Facebook and on Instagram @jitterbuscoffee) reveals engine troubles, brutal weather, and the occasional celebrated appearance of Nari, a friend’s dog. The labor needed to make repairs on the bus, both Dan and Paul say, is the worst part about working for themselves. But still, they wouldn’t have it any other way.

[“Source-connecticutmag”]

Trio of Starbucks Rejects Delivers Java Fix to New Haven

IMG_1186.jpg

There is something wonderfully freeing about working in a food truck. The job seems to appeal to a certain free spirit, that individual who can’t quite fit into an office or even a kitchen in a restaurant. In a food truck, you are the king of your own domain. No bosses, no suit, just a view of whatever corner of the world you choose through a small window as waves of people come by to sample your wares. You listen to whatever music you choose, and approach the job whichever way you want.

The three New Haven 20-somethings who own and operate the Jitter Bus coffee truck in the Elm City — Dan Barletta, Paul Crosby and Andrew Mesiouris — are not huge fans of bosses. Having met as teenagers in West Haven, all three have been fired from Starbucks at one time or another. “You’re not cut out for this job,” Barletta says they told him when they let him go.

Well, joke’s on them. Now Barletta makes a living with his friends, working for themselves and each other, selling coffee on their own terms. Crosby, who has SINK and SWIM tattooed on the knuckles on his respective hands and was fired from a Starbucks in West Haven, says this has been the idea for him from the start. “It’s been my plan since I was in like fifth or sixth grade. It was a tattoo shop when I was young, but as I fell out of that, I grew into this,” he says.

Aesthetically, the Jitter Bus looks like what the Addams Family would come up with if they quit television and became do-it-yourself punks and tattoo artists. The old school bus is painted black with white designs hand-painted on. The Jitter Bus’ goth color scheme stands out amid the proliferation of brightly painted food trucks that populate our cities. Its one-year anniversary party was held back in March at Keys on Kites Tattoo & Gallery in New Haven’s Westville section, where they had a music show and raffled off a free tattoo.

 The do-it-yourself attitude is not a hollow one. The guys in the Jitter Bus have built most of the mobile cafe’s components. Water tanks, counter tops, shelves, bus mechanics, even the swivel tray that holds the iPad cash register: all were built and designed by the three owner-operators.

On a blisteringly hot June day at their usual spot at the corner of Hillhouse Avenue and Grove Street, the boys on the bus are serving up hundreds of coffees ($2-$2.50), cappuccinos ($3.25-$3.75), cortados ($3.25), mochas ($4.25-$5), espressos ($2), chai ($3.50-$4) and the iced versions of all of them ($3-$5). Extra espresso shots can be added for 75 cents, and flavor shots of vanilla, hazelnut, caramel and coconut for 50 cents.

They get all their coffee from Connecticut, mostly from the Canton micro-operation Giv Coffee, and its excellent espresso blend Star Breather, sourced from Peru and Brazil with notes of dark chocolate, raisin and almond. Newington’s Saccuzzo Coffee Co. also provides beans, while pastries come from New Haven’s Whole G bakery and milk and cream from Connecticut-sourced Farmer’s Cow.

Despite the heat, there is a steady stream of people coming up for their usual fix. “We’re pretty much legal drug dealers,” says Crosby. “We sell it on the corner and everything,” Barletta adds after a laugh. The hundreds or even thousands of hole-punched loyalty cards oozing from every crack in the truck testify to the popularity of the truck and the regularity with which its patrons return. (While Hillhouse and Grove is their usual corner, the Jitter Bus is available for booking for events and festivals.)

A digital stroll through the Jitter Bus’ social media (follow The Jitter Bus on Facebook and on Instagram @jitterbuscoffee) reveals engine troubles, brutal weather, and the occasional celebrated appearance of Nari, a friend’s dog. The labor needed to make repairs on the bus, both Dan and Paul say, is the worst part about working for themselves. But still, they wouldn’t have it any other way.

[Source:-.connecticutmag]

Stanford University dumps Java as an introductory programming language

It’s pretty much known to anyone in the programming world that Java is one of the hardest languages to learn right off the bat; that is if you’ve never written a line of code in your life. Well, Stanford University agrees, and has decided that to make programming more accessible to its students, something drastic had to be done.

In its latest update to the Programming Methodology course code CS 106J, the University replaced the difficult to master Java language that was present in CS 106A, with the more palatable language JavaScript. Even though to the layman the difference might seem arbitrary just from the namesake; but in reality, this makes programming easier to understand mainly due to the latter having less ‘bloat’ to contend with.

This change was spearheaded by Eric Roberts, an Emeritus Professor, who pioneered the CS 106 series. When he joined the University, programming was still based on Pascal. After Java became a popular language, Stanford enthusiastically transitioned. But according to this Professor, Java is ‘showing its age’, and he has been working on this project for the past five years, writing new textbooks and the like. This move is aimed at completely transition to JavaScript for the CS 106 program because of the fact that according to Roberts, it has become the ‘language of the internet’.

A small example of the difference between the two languages makes it pretty clear that it might be time for a change.

Hello World app built in Java:

class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, world!”);
}
}

Now that same app built in JavaScript:

alert(‘Hello, world!’);

Although Java currently holds the top spot when it comes to programming languages, making it easier for students to learn programming will encourage them to acquire these skills. Java is being used to program applications for Android amongst other things, which makes it a requirement when working in the programming field. But this change is mainly there to help students get into the concepts behind programming, instead of drowning them in ‘Public Static Void’ like jargon.

With the digital world becoming more enshrined with our daily lives, having more educated people know how to code will only benefit us in the long run. As for how successful this change in language will be at retaining students in the long haul, remains to be seen.

[“Source-neowin”]

Get your Java errors under control with error monitoring

Java errors

Java became a go-to language for Web-facing applications and Internet projects. However, the use of Java is not without its potential pitfalls, and that’s something that’s important for developers to keep in mind. In this article, AJ Philips teaches you how to get your Java errors under control with error monitoring.

The Java programming language is immensely popular with developers and has been for many years. It’s not just a case of having another object-oriented programming language to build applications with – Java’s rise coincided with the emergence of embedded web programming.

Java became a go-to language for Web-facing applications and Internet projects.
However, the use of Java is not without its potential pitfalls, and that’s something that’s important for developers to keep in mind.

The root of the problem(s)

Some of the common code problems in Java relate to the semantics that programmers use to build a code base. Without the right syntax, compiler errors and other errors can result.

Consider the omission of a closing bracket or parenthesis on a declaration or command. This type of mistake will generate an “expected” error and has to be fixed for proper execution. Another similar error is the “unclosed string error” where a string is not closed out with a quotation mark.

Another common error called “incompatible types” happens when integers or strings or other data types are used improperly, or combined in ways that don’t work for the program. Trying to assign one type of data type variable to another may create an “incompatible type” error. Other malformed syntax can produce an error called “invalid method declaration” or an “unreachable statement” error, or one stating an operator cannot be applied correctly.

What all of these mistakes have in common is that they arise from syntax that’s not properly and precisely controlled. It only takes one keystroke to make the errors, and they’re a minefield for programmers who may be meticulous in their writing, but still experience the occasional misplaced character while typing.

SEE ALSO: The error tracking tools Java developers should know

Automating the error correction

In the early days of object-oriented programming, there weren’t a lot of tools to catch the errors. Code base work could be tedious and labor-intensive – programmers had to catch the errors or fight them when trying to compile the program. This generated a lot of protocol in programming offices and oversight of individual programmers and their work.

Today’s developers have other options — the advance of digital analytics means programs can be created to automate some of the error correction that used to be done by hand.

These types of automation programs are immensely valuable in developer communities. Developers understand that they can bring products to market more quickly, fine-tune a codebase, and work more efficiently with tools that feature automated processes. Many of these tools also have combined features offering more research capability, so that developers can work better on the fly and do various kinds of required investigation while they are putting code together.

Improving the world of Java

The Stackify platform has a lot of this valuable functionality in place. Stackify looks at blogs, monitoring, metrics and available tools, and offers developers real assistance or getting where they need to go. The company calls the products “a magical developer map” in which professionals can find problems quickly and solve them actively and decisively.

When it comes to assisting developers, insight and transparency are key. Troubleshooting application problems can lead developers down some very dark paths — and without modern tools like Stackify, troubleshooting can take a lot of time. However, with these new tools and platforms, there is a way through these complicated processes. Stackify Retrace helps developers to effectively retrace what the code is doing so that bugs and glitches have nowhere to hide. Take a look at how Stackify can improve the world of Java.

[“Source-jaxenter”]

Bus accident kills 10 in Indonesia, traveling from Bali to Java

Image result for Bus accident kills 10 in Indonesia, traveling from Bali to JavaPhoto: Pixabay

At least 10 people, including a foreigner and a child, died when a bus hit the back of truck early Friday as it traveled from the resort island of Bali, police said.

The bus, carrying 34 people, was heading to the town of Malang in East Java in the early morning when it hit the back of a fertilizer truck, killing several of the sleeping passengers.

“Ten people died on impact and nine others were injured,” local police chief Arman Asmara Syarifuddin told AFP.

Among the victims were a 29-year-old Austrian man whose name has not yet been released and a 12-year-old Indonesian girl.

A German tourist was also injured in the accident and has been released from hospital after receiving treatment, Syarifuddin said.

Police have detained and questioned the drivers of the truck and the bus to determine the cause of the accident.

Transport accidents are common in Indonesia, where buses and trains are often old and badly maintained.

At least 11 people were killed and 50 others were injured in April when a bus rammed into several other vehicles in West Java province after a suspected brake failure.

[“Source-coconuts”]

Java joins FCSD family

Welcoming Java

New River Gorge Harley Owners Group Chapter #2019 recently made a donation to help the Fayette County Sheriff’s Department in costs related to obstaining, equipping and training the department’s newest member of the K9 Unit.

Java is trained as a bomb-sniffing dog and puts the number of K9s with the department at five.

NRGHOG is a motorcycle riding organization based at New River Gorge Harley-Davidson in Hico. Each year, NRGHOG obtains funding through membership dues, making apple butter in October and other projects to support local charities. The organization then votes to support organizations and charities in and around Fayette County.

NRGHOG thanks the Fayette County sheriff and deputies for their dedication and service to our community.

[“Source-montgomery-herald”]

Nipun “Javatinii” Java Clicks His Way to 2nd Bracelet of the Summer in $1,000 WSOP.com Event

Nipun Java

SHARELINES

It didn’t take Nipun “Javatinii” Java days to win a World Series of Poker gold bracelet. No, it only took them a little more than half a day. Java took on a field of 951 players and emerged victorious after just 14 and a half hours. For his victory, he won $237,668 as well as his second World Series of Poker gold bracelet of the summer after coming out on top in the $1,000 Tag Team Event back in June together with Aditya Sushant.

It was with 20 players left that Java first made it onto the radar. He picked off a bluff from “topkoks”who was running extremely hot at the time, eliminating three players in the span of 20 minutes. Java made a call with just top pair to pick off “topkoks” all-in bluff shove on the river to become the chip leader with 20 left. From there it was easy riding for Java to make the final table.

Java exchanged the chip lead several times with “WhyTry” who ended up finishing in 11th place for $13,211. In one hand, Java flopped a full house and was able to get tons of value out of “WhyTry” to put a stranglehold on the top position. Java then eliminated “AznBlazer469” in 10th place to come to the final table in second place just behind Jason “jadedjason” James who eventually finished 2nd.

Java stayed mostly quiet for the final table, picking good spots and waiting to have the goods to get it in. He eliminated Sean “Hurricane27” Legendre in 7th place in a cooler spot where Legendre had kings and “Javatinii” was holding aces. Again, during four-handed play, Java called a shove from Evan “YUDUUUUUUUUU” Jarvis, when Java was holding kings and Jarvis was only holding nine-ten off. Java held up and took the chip lead with just three players left.

Heads-up play lasted for a while with James doubling up first by winning a coin flip with pocket eights against Java’s ace-ten, but Java doubled right back with ace five against James’ pocket queens after an ace hit the turn. The end of it all came when Java flopped two pair against James’s flush and straight draws. The turn and river bricked out and Nipun “Javatinii” Java was able to take down the tournament and the $237,668 first prize.

Place Player Name Country Prize (USD)
1 Nipun “Javatinii” Java United States $237,668
2 Jason “jadedjason” James Canada $146,202
3 Richard “jklolz” Tuhrin United States $103,326
4 Evan “YUDUUUUUUUUU” Jarvis Canada $73,911
5 Vinny “Mr_Sinister” Pahuja United States $53,595
6 Jeffrey “Jeffrey27rj” Turton United States $39,510
7 Sean “Hurricane27” Legendre United States $29,415
8 Steven “meditations” Enstine United States $22,185
9 Stanley “stanman420” Lee United States $17,075

That wraps up Event #71: $1,000 WSOP.com Online No-Limit Hold’em but Saturday marks the beginning of Event #73: $10,000 No-Limit Hold’em Main Event – World Championship, and PokerNews will be here with coverage of it all, so don’t miss a thing.

WSOP Online Event

Be sure to complete your PokerNews experience by checking out an overview of our mobile and tablet apps here. Stay on top of the poker world from your phone with our mobile iOS and Android app, or fire up our iPad app on your tablet. You can also update your own chip counts from poker tournaments around the world with MyStack on both Android and iOS.

[“Source-pokernews”]

VertxUI: Java as a front-end language

© Shutterstock / Grumble

Why waste time on learning new language features and lots of frameworks, taking the risk that you’re learning tools that won’t ever be updated again? There is a language that can run anywhere too, except directly in a browser. What if Java could directly run in a browser? In this article, Niels Gorisse, a senior full-stack Java developer, presents the benefits of VertxUI.

Yesterday I had a job interview for a senior Java back-end job. They asked me whether I was a full-stack developer or not. Although my answer was a proud yes, I stated that I don’t really like JavaScript, but I can find my way through HTML/CSS and JavaScript code. Then I had to explain why I don’t like JavaScript.

I said I don’t like it because of many reasons. JavaScript doesn’t – or actually: didn’t – work the same on all browsers, there is a global scope with all variables in it, and besides that, there are thousands of libraries fixing missing language and API features. Even worse, it seems none of them can be considered to be ‘default.’ So, there is no chance of knowing whether you’ve picked the lasting libraries. I guess I did not get the job.

Just like most senior Java developers, I wrote my first JavaScript lines of code well before 2000. Of course, that is the reason for my grunge against it. But things have changed. Nowadays, after more than ten years of browser disaster, ECMAscript5 has become the standard: more than 97% of all browsers in use support it. Yes, JavaScript still has the ugly language features, but you can write a piece of JavaScript code that works anywhere. And JavaScript is becoming a decent language complete with classes, exceptions, lambda notation, worker thread, packaging, annotations, futures, library management, and much more.

But why waste time on learning new language features and lots of frameworks, taking the risk that you’re learning tools that won’t ever be updated again? There is another language that can run anywhere too, except directly in a browser. What if Java could directly run in a browser?

Mind you, many features which are fairly new to JavaScript have been added to Java many years earlier. In almost every case, this means they’ve become pretty stable and mature over the years:

VertxUI and Fluent

VertxUI is a 100% Java library which tries to answer what if we could run Java directly in the browser. And because pure HTML with CSS is enough to build web pages, VertxUI provides – besides low-level access to the browser – also a lightweight fluent API called Fluent, which simplifies building HTML and CSS with code only. Fluent works with method names corresponding to HTML tags. The first argument of these methods is always a CSS class. So VertxUI does not have any templates, just code. Consider a menu in bootstrap. Using HTML, we’d define a Bootstrap menu like so:

1
2
3
4
5
6
7
8
9
10
11
12
<ul class="nav navbar-hav">
  <li class="active"><a href="#home">Home</a>
  <li><a href="#about">About</a>
</ul>
Using Fluent, we can use to generate the same HTML code like so:
...
Fluent ul = body.ul("nav navbar-nav");
ul.li("active").a(null, "Home", "#home", controller::onMenuHome);
ul.li(null).a(null, "About", "#about", controller::onMenuAbout);

The variable body is a static import from the class Fluent. Similarly, you can also use the methods console, document, and window.

Actually, the Java source code generates code doing slightly more than the HTML snippet above. It also shows how to call Java code when clicking a menu entry. In our example, an instance of a controller (controller::someMethod) takes care of the event handling.

Although not displayed in the previous snippet, there is also a class Store, maintaining a list of class Model. This traditional MVC (model-view-controller) setup is not necessary, but it turns out to be useful when writing JUnit tests.

Of course, you can also use the lambda notation too. For example, let’s create a Bootstrap form. The methods .css() and .att() are also used to show you how they work. This is basically all you need to write HTML and CSS:

Desired HTML snippet:

1
2
3
4
<div class="form-group">
  <label style="font-size: 200%" for="n">Wat</label>
  <input class="cssClass" type="text" id="n">
</div>

Generating the some code using Fluent:

1
2
3
4
5
6
7
8
Fluent div = body.div("form-group");
div.label(null, "Wat")
   .style(Style.fontSize, "200%")
   .att(Att.for, "n");
div.input("cssClass", "text").id("n").
    keydown( (fluent, keyEvent) -> {
      console.log("You typed: " + fluent.domValue());
    });

How it’s done

Of course, the Java code isn’t run in the browser. It’s compiled to JavaScript before. At this point, people often get a wrong impression when they hear which compiler is used, so let’s mention first that VertXUI has been developed using TeaVM. However, TeaVM wasn’t without flaws. In particular, there were a couple of bugs concerning Lambdas. So now VertxUI uses the cross-compiler of GWT to do that, but without using the original GWT toolkit. Don’t confuse it with Vaadin or GWT itself. VertxUI is a completely different, unique approach.

View on … model

The real power of Fluent shows when you are about to change the DOM – because you don’t have to. Changes are updated as efficiently as possible, comparable to ReactJS (from Facebook) which makes sure that your Facebook list of friends does not get completely re-rendered when one online status changes.

You can create a ViewOn<Model> with the .add() method. This takes two arguments: an initial model (or reference to a model) and a method translating this model to a Fluent object. For example:

Result

1
2
3
4
5
6
7
8
9
<table>
  <tbody class="striped">
  (per subscribed person:)
  <tr>
    <td class="fat">*name*</td>
    <td>*quantity*</td>
  </tr>
  </tbody>
</table>

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public View {
  private ViewOn<List<Person>> table;
 
  public void start(Controller controller){
    List<Person> initialPersons = controller.getPersons();
 
    Fluent middle = body.div();
    ...
    table=middle.add(initialPersons, persons -> {
      if(persons == null || persons.isEmpty()) {
        return Span("big","No people yet");
      }
      Fluent result = Table().tbody("striped");
      for(Person person:persons) {
        if(person.isSubscribed()) {
          result.tr(
              Td("fat",person.getName()),
              Td(null,person.getQuantity()));
        }
      }
      return result;
    });
  }
 
  public void syncPersons() {
    table.sync();
  }
}

You probably noticed the syncPerson() method. This redraws all ViewOn objects having a link to the Person entity. As said previously, you do not need a controller, but here the controller calls that method after a change. Note that it is quite easy to write quite complex user interfaces (like wizards) because you’re just declaratively writing down what your UI should look like. You can even nest ViewOn objects.

All code is pure Java, so if you prefer streams, then that is no problem. The tbody – just like a lot of other containers like tags – takes a CSS class and a list or stream of Fluent objects.

1
2
3
4
5
6
7
8
9
10
table = middle.add(initialPersons, persons -> {
  if (persons == null || persons.isEmpty()) {
    return Span("big", "No people yet");
  }
  return Table().tbody("striped", persons
      .filter(person -> person.subscribed())
      .map(person -> Tr(
          Td("fat", person.getName()),
          Td(null, person.getQuantity()))));
});

View on … state

In the previous Bootstrap menu example, the CSS item which has the “active” class should switch to the selected one when you click on it. This is what we can call a ‘state.’ It is handy to recognize a state and to treat it as an entity which happens never to be saved into a database. You can also use ViewOn<> for a state:

1
2
3
4
5
6
7
String initState = "home"; // or something else which you have extracted from the URL
...
Fluent menu = body.add(initState, state -> {
  Fluent ul = Ul("nav navbar-nav");
  ul.li(state.equals("home") ? "active" : null).a(null, "Home", "#home", controller::onMenuHome);
  ul.li(state.equals("about") ? "active" : null).a(null, "About", "#about", controller::onMenuAbout);
});

JUnit – unit testing

Because Fluent has a virtual DOM internally, you can easily ‘abuse’ this for JUnit testing without firing up a browser. This is extremely fast because there is no compilation to JavaScript and there is no starting and stopping of a browser in the background.

In practice, the class Store is often mocked in JUnit tests to prevent network traffic, but in the next example we mock the Controller call directly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Test {
 
  @Test
  public void test() {
    // Fake result after some network traffic
    List<Person> persons = new ArrayList<>();
    String name = "John " + Math.random();
    persons.add(new Person(name, 2000, true));
   
    // Startup sequence
    View view = new View();
    Controller controller = Mockito.spy(Controller.class);
    Mockito.when(controller.getPersons()).thenReturn(persons);
    view.start(controller);
   
    assertEquals("1 row",1,VirtualDomSearch.getElementsByTagName("TR", body));
    List<Fluent> tds = VirtualDomSearch.getElementsByTagName("TD", body);
    assertTrue("2 columns", 2, tds.length());
    assertTrue("name test", name, tds.get(0).txt());
  }
}

JUnit – integration tests
As your project grows and starts using external JavaScript libraries, integration tests get more and more important. In Fluent you can perform dual-language tests in a headless browser with a ‘register-and-run’ construction. You have slightly more control over your runtime environment than with Selenium because you can easily run and combine JavaScript assets and Java assets together in one test-run.

As an example, we take that dull first Bootstrap menu example, and we simulate a menu click by directly calling controller.onMenuAbout(). Let’s see whether the previous example, which changes the content of the ‘active’ class, actually works. The following code is really all you need. The Java-to-JavaScript compilation happens on the fly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Test extends TestDOM {
 
  @Test
  @GwtIncompatible
  public void test() throws Exception {
    System.out.println("Java");
    runJS(100); // run slot '100'
  }
 
  @Override
  public Map<Integer, Runnable> registerJS() {
    Map<Integer, Runnable> result = new HashMap<>();
    result.put(100, () -> testWithDOM()); // register slot '100'
    return result;
  }
 
  public void testWithDOM() {
    console.log("JavaScript");
     
    View view = new View();
    Controller controller = new Controller(new StoreEmpty(), view);
    view.start(controller);
 
    // search the active menu item
    NodeList actives = document.getElementsByClassName("active");
    assertEquals("quantity test 1", actives.length(), 1);
    assertTrue("titletest 1",((Element) actives.item(0).getChildNodes().at(0))
      .getTextContent().equals("Home"));
     
    controller.onMenuAbout(null, null);
     
    // search again
    actives = document.getElementsByClassName("active");
    assertEquals("quantity 2", actives.length(), 1);
    assertTrue("titletest 2",((Element) actives.item(0).getChildNodes().at(0))
      .getTextContent().equals("About"));
  }
}

Notice that this example could have been put in a non-DOM test, which runs a lot faster.

VertX

You can run VertxUI in any back-end software, but together with VertX, it provides several facilities like FigWheely and POJO traffic. VertxUI with VertX is easier than easy: just start the main() and point your browser to http://localhost. You don’t have to install any IDE-plugin. Neither do you have to deal with a *.war or *.jar. Just start the main class, and you’re good to go!

VertX is completely asynchronously and works with callbacks, just like JavaScript. So, for example, it doesn’t block until TCP data has arrived, but instead it will continue to run the stack when something has arrived. The big difference is that because Java is a very structured language, you’ll never get a callback hell like in JavaScript. You will probably call another method in another class when something asynchronously has happened.

VertX – FigWheely

FigWheely is the runtime helper of VertxUI. It keeps a WebSocket open with the browser and receives notifications when files have changed on the server. If the files that have changed happen to be .java files, FigWheely will recompile your browser code and notify the browser too.

FigWheely works -just like VertxUI- without any IDE-plugin because the compilation to JavaScript happens when you start the (VertX) server and when the source code is found. During startup, a one-line index.html is also generated, but you can also turn this off to use an existing website. Or you can use HTML itself as HTML template when using jQuery Mobile.

VertX – POJO

VertxUI facilitates POJO traffic between server and browsers for ajax calls, WebSocket, sockJS, and the VertX event bus. This means strong-typed traffic, even though JSON is used underneath. Having the client and server in the same language has quite some nice advantages: when you want to add a table column, it might just be adding one line of code to the entity and one line for an extra ‘TD’ in the view.

Here is a client-side example of a chat application with a POJO receiver:

1
2
3
4
5
6
7
8
9
10
WebSocket socket = window.newWebSocket("ws://localhost/chatWebsocket");
socket.setOnmessage(event -> {
  // POJO: receive the a color and put it between a new <li>...</li>
  if (POJOfy.socketReceive(urlPOJO, event, POJOMapper,
    pojo -> messages.li("colored", "Received: " + pojo.getColor()))) {
    return;
  }
  // otherwise, receive the text and put it in a new <li>..</li>
  messages.li("flat", ((MessageEvent) event).getData().toString());
});

and here is the server side, which can also receive a POJO. It looks so simple that you might forget that this is an extremely powerful web server, more powerful than a regular locking multithreaded servlet environment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
List<String> ids = new ArrayList<>(); // all ids
vertx.createHttpServer().websocketHandler(socket -> { // entering
  String id = socket.textHandlerID();
  ids.add(id);
  socket.closeHandler(data -> { // leaving
    ids.remove(id);
  });
  socket.handler(buffer -> { // receiving
    if (POJOfy.socket(socket, View.urlPOJO,buffer, Dto.class,aService::handle)){
      return;
    }
    String message = buffer.toString();
    ids.forEach(id -> vertx.eventBus().send(id, message)); // broadcasting
  });
}).listen(80);

Wrapping it up

No matter what happens in the future with the client side and the JavaScript language, you can already create very well testable single page web applications in the very grown-up language Java backed by the well developed VertX server environment and backed by any well-developed CSS framework like Bootstrap. The test facilities of VertxUI alone should be interesting enough to try out VertUI for a new project. Let alone the POJO traffic, strong-typed code, a well developed IDE, and so forth, in other words: Java.

JavaScript and its libraries will grow up, but this will take years, and the chances are small that you can pick the right libraries now and prevent refactoring and learning new language features that get deprecated before you’re used to them.

If you’re familiar with React.js or Angular, you’re used to just changing the model to update the view. Actually, this seamless integration between the view and the model made React and Angular popular. It was a major improvement over the older approach modifying the DOM manually. Changing the DOM is error-prone. Using a framework for that makes you write clean code. VertxUI brings this idea to the Java world.

This article was originally published on Beyond Java. 

[“Source-jaxenter”]

Eclipse gets ready for Java 9 with Oxygen release train

Eclipse gets ready for Java 9 with Oxygen release train

Credit: Thinkstock

The Eclipse Foundation’s annual release train, featuring simultaneous updates to dozens of projects, has just arrived, featuring preliminary Java 9support. Called Oxygen, the release train covers 83 projects and includes 71 million lines of code.

Here are the key updates in Oxygen:

  • Java 9 support remains in beta stage, because Java 9 itself will not be made available until Java Development Kit 9 ships on September 21. Oxygen’s Java 9 support includes the ability to add the Java Runtime Environment for Java 9 as the installed JRE as well as backing for the Java 9 execution environment. Developers also can create Java and plug-in projects using Java 9 and compile modules that are part of a Java project. Eclipse’s signature Java IDE has been enhanced as well, with improvements to the UI.
  • Eclipse Linux Tools 6.0 updates Docker Tools with more security options. This project provides a C/C++ IDE for Linux developers.
  • Eclipse PDT (PHP Development Tools) 5.0 supports the 7.1 version of PHP, which offers nullable types and a void return type.
  • The Eclipse Sirius 5.0 platform for building domain-specific modeling tools, with usability enhancements.
  • Eclipse EGit 4.8.0, offering performance and usability for the Java implementation of Git code management integration for Eclipse.

Focused on open source tools, Eclipse has offered annual release trains every June since 2006, letting developers coordinate upgrades or new releases of multiple projects. Last year’s release train, Neon, offered tools for Docker and JavaScript. June 2018’s release is slated to be called Photon.

[“Source-infoworld”]