mardi 4 août 2015

How do i use void with methods in Java?

public String firstMethod() {
    System.out.println("Hello!");
    return 'Done!';
}

and

public void secondMethod() {
    System.out.println("Hello!");
    return 'Done!';
}

Please, don't tell me "Void returns a value". Where does it return, how, and why do i need to use this? How can it be benefit from using?

Export Function in Display Tag

I am working on one migration project(Struts --> Spring MVC) but without changing the UI parts. The place where I stuck is my table using Display Tag. I am using Display tag to show data in tabular format like below.

<display:table style="width:100%" name="sessionScope.list" id="listID" export="true" sort="list" pagesize="20" defaultorder="ascending">
    <display:column property="rowNumber" title="#"/>
    <display:column property="issuerName" title="Issuer Name" sortable="true" paramId="in" paramProperty="issuerName" />
    <display:column property="contractNumber" title="Contract Number" sortable="true"/>
    <display:column property="ip" title="IP" sortable="true"/>
    <display:column property="maturityDate" title="Maturity Date" sortable="true"/>
</display:table>

As we know marking export="true" gives us "Export options" with options like CSV, Excel, XML.

My problem is, the link that is generated on each options is like below

http://localhost:8080/myWebApp/WEB-INF/pages/myjsp.jsp?d-445967-e=1&6578706f7274=1

As you can notice, its like jsps path which is inside WEB-INF folder. That can not be accessed from outside. But in my old application this link appears as below.

http://server:port/myAppName/myJspName.jsp?d-445967-e=3&6578706f7274=1

Since this was an Struts application so folder struct was little different where we had JSPs outside

WEB-INF folder.

Same issue I am facing with pagination links.

Thanks

Hibernate JPA Joined Inheritance

I have a project with a part of the data structure made with @Inheritance(strategy = InheritanceType.JOINED). That part of the data structure looks something like this:

enter image description here

The design is based on the thoughts in this article. I'm using Hibernate with JPA2 interface as my datalayer. The structure above has resulted in the following pojo/dao classes (getters and setter omitted):

BaseItem:

@Entity
@Table( name = "base_item" )
@Inheritance(strategy = InheritanceType.JOINED)
public class BaseItemPojo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;
}

PhysicalItem:

@Entity
@Table( name = "physical_item" )
public class PhysicalItemPojo extends BaseItemPojo{
}

SomeHardware:

@Entity
@Table( name = "some_hardware" )
public class SomeHardwarePojo extends PhysicalItemPojo{
}

SomeOtherHardware:

@Entity
@Table( name = "some_other_hardware" )
public class SomeOtherHardwarePojo extends PhysicalItemPojo{
}

Here is my issue:

One of my other tables has a reference to the base_item class, and it would make my life a lot easier, if that class loaded either the "some_hardware" or the "some_other_hardware" based on that base_item_id. Hence, I made navigation properties like this on that particular class:

@Entity
@Table( name = "some_navigation_class" )
public class SomeNavigationClassPojo{
    @ManyToOne(optional = false)
    @JoinColumn(name="base_item_id", insertable = false, updatable = false)
    private BaseItemPojo baseItem;

    @ManyToOne
    @JoinColumn(name="base_item_id", insertable = false, updatable = false)
    private PhysicalItemPojo physicalItem;

    @ManyToOne()
    @JoinColumn(name = "base_item_id", insertable = false, updatable = false)
    private SomeHardwarePojo someHardwarePojo;

    @ManyToOne()
    @JoinColumn(name = "base_item_id", insertable = false, updatable = false)
    private SomeOtherHardwarePojo someOtherHardwarePojo;
}

As you might have guessed, the above didn't work. If I try to access a "SomeNavigationClassPojo" that has a related "SomeHardwarePojo" attached to the entity, I get the following error:

java.lang.IllegalArgumentException: Can not set SomeOtherHardwarePojo field SomeNavigationClass.someOtherHardware to SomeHardwarePojo.

For reference, my goal is that if either someHardwarePojo or someOtherHardwarePojo doesn't exist in the database, they should just be set to null, and not tried to be mapped to respective other child of PhysicalItemPojo

Deployed JavaFX Application with embedded JRE not startable on some systems

The Application gets deployed via Java FX Packaging Tools and is bundled with the JRE (8u40, 32bit). The resulting Ant File was extended by us to run unit-tests and stuff like that. Since we want to support custom locations, we don´t use the generated FX-Installer. So the generated bundles/[appname] folder gets zipped and extracted on the target systems. Usually the application runs fine, but on some systems we experience a weird issue.

When the user tries to start the application via generated .exe file, the application does not start. Nothing happens, no runtime errors, no system errors, just nothing at all. The same happens, when I try to start the .jar directly. Unfortunatly the clients have no rights to use the terminal, so I can´t launch the application from there.

The system, where this behavior occurs is Windows 7. For debugging purposes I added a simple Swing frame before starting the application, but this one isn`t starting either. No log-files where created, so I guess the application does not start at all.

Does anyone know if there is any chance to find out, what is going wrong during the start of the application and/or the runtime enviroment?

LDAP Sub Query to fetch SamAccountName from CN

Currently I have this query as mentioned below which returns all users but each user has a parameter called manager which returns "CN=Peder Ellingsen,OU=Users,OU=NO,OU=Countries,DC=xds,DC=xxx,DC=com"

Need the samAccountName instead of the CN above ,need help with LDAP Subquery which can help me to get the SamAccountName directly by modifying the query mentioned below

Wanted to avoid double hits to ldap server just to get the SamAccountName.

(&(objectCategory=person)(objectClass=user)(memberof=cn=MyCompass_NO,OU=Groups,OU=Common,OU=Applications,DC=xds,DC=xxx,DC=com))

ModelAttribute Values are not populating values

I have a form as shown below

    <!DOCTYPE html>
<html>
<%@ taglib uri="http://ift.tt/QfKAz6" prefix="c" %>
<head>
    <meta charset="utf-8" />
    <title>Dealer Details</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
    <link href="css/app.css" rel="stylesheet" />
    <script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
    <script type="text/javascript">
        function onChange() {
            var value = ($("#jsonTextArea").text());
            alert(value);
            document.getElementById("jsonTextHidden").value = value;
        };
    </script>
</head>
<body class="body-bg">
    <form modelAttribute="jsonString" method="post" action="postHome">
        <div class="container">
            <div class="col-sm-8 col-sm-offset-2">
                <div class="row">
                    <div class="col-md-6 col-md-offset-3">
                        <div class="centerediv">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h3 class="panel-title">Select Home</h3>
                                </div>
                                <div class="panel-body">
                                    <div class="form-group">
                                        <textarea rows="4" cols="40" name="jsonTextArea"></textarea>
                                    </div>
                                    <input class="btn btn-danger" type="button" value="Cancel">
                                    <input class="btn btn-success" type="submit" value="Ok" onclick="onChange();">
                                    <input type=hidden id="jsonTextHidden" name="jsonTextHiddenField" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>

I have a controller class as shown below.

@Controller
public class HomeController {

    @RequestMapping(value = "/home", method = RequestMethod.GET)
    public String callHomePage() {
        return "home";
    }

    @POST
    @Consumes({MediaType.APPLICATION_XML})
    @RequestMapping(value = "/postHome")
    public ModelAndView postHomeList(@ModelAttribute("jsonString") HomeRequest request, @Context HttpServletRequest servletReq, @Context HttpServletResponse servletRes) {
        ModelAndView mav = null;
        System.out.println(request.getHomeId());
        return mav;
    }

}

In this home.jsp a textarea field is there where I can enter some values ( json string ). After submission the value for request.getHomeId() is coming as null. Can any one help me to solve this issue?

How to format time from Android's TimePicker?

Hi I am currently using a TimePickerDialog to set the time and display it into a text view. However, I am having problems with the formating. This is my code

    TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() {
    @Override
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        if ((hourOfDay >= 1) && (hourOfDay <= 11.59)) {
            hours = hourOfDay;
            am_pm = "AM";
        } else if (hourOfDay >= 12) {
            hours = hourOfDay - 12;
            am_pm = "PM";
        } else if (hourOfDay == 0) {
            hours = 12;
            am_pm = "AM";
        }

        tvScheduleTime.setText(hours + " : " + minute + " " + am_pm);

    }
};

This method works in retrieving AM and PM but the numbering is weird, like 6:08 AM becomes 6:8 AM. How can I make it so that it creates the text HH-MM AM/PM?

ParameterizedAssertionError in JUnit Theory

The following test throws a ParameterizedAssertionError. It seems that both parameters of the test method get the same argument, although they are of different types.

import java.lang.reflect.Field;
import java.util.ResourceBundle;

import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;

@RunWith(Theories.class)
    public class ErrorIDsTest {

    @DataPoints
    public static Field[] errorIDs() {
        return ErrorIDs.class.getDeclaredFields();
    }

    @DataPoint
    public static ResourceBundle bundle = null;

    @Theory
    public void testThatFails(Field field, ResourceBundle bundle) throws Exception {
    }

    interface ErrorIDs {
      public final String Fehler = "ErrorIDs.Fehler";
    }
}

The exception is ParameterizedAssertionError

org.junit.experimental.theories.internal.ParameterizedAssertionError: testThatFails(errorIDs[0], errorIDs[0]) at org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:183) at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:138) ...

I used an example from here ParameterizedAssertionError in Theory but facing exactly the same. It's fixed but I'm not using the same .jar. Is there any other fix to resolve this?

Firebase returning keys of child node in different orders on different devices/Android versions

I am getting a snapspot of the data from my Firebase database to retrieve a users list, but the order of the keys being returned is different depending on the Android version/ device being used.

For demonstrative purposes I have shortened the method, but it is essentially as follows:

public void getUsers(){

Firebase ref = new Firebase("http://ift.tt/1eQ0zaI");

    final Firebase userRef = ref.child("users");

    userRef.addListenerForSingleValueEvent(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot snapshot) {


           snapshot.toString();

                                                           }                                                           
                                                                  });
                           }

It is the data I get from calling toString() on the snapshot object (snapshot.toString()) that changes order.

I have tried it on 4 devices. The 2 running Lollipop (Nexus 7 5.1.1 & Galaxy s4 5.01) return the data in the same order. And the 2 two other devices (HTC Sensation 4.0.3 and Motorola G2 4.4.4) return the data in the same order (but a different order to devices with Lollipop).

There is no difference in the code used, and the data in the database was completely unchanged at the times when I retrieved the snapshots.

Here is the data order on the 4.4.4 and 4.0.3 devices:

DataSnapshot { key = users, value = { 114585619420240714499={userIDOfCUser=114585619420240714499, NameOfCUser=testName, EmailOfCUser=testerfireapp@gmail.com, friends={103902248954972338254={userIDOfFriend=103902248954972338254, NameOfFriend=testName2 }}}

Here is the data order on the 5.1.1 and 5.01 devices:

DataSnapshot { key = users, value = {114585619420240714499={NameOfCUser=testName, userIDOfCUser=114585619420240714499, friends={103902248954972338254={NameOfFriend=testName2 , userIDOfFriend=103902248954972338254}}, EmailOfCUser= testerfireapp@gmail.com}}}

Why is the data being delivered in different orders depending on the android version/device being used? is there another difference I am unaware of ?

Thanks in advance.

NullPointerException in JCodec with .mkv

I want to get all frames from video in jpg. For .mp4 file program works great but for .mkv i got NullPointerException I don't know why. I use JCodec

public static void Frames(File video, String destiny){
    boolean check = true;
    int i = 1;

    while (check == true) {
        try {
            BufferedImage frame = FrameGrab.getFrame(video, i);  //22
            ImageIO.write(frame, "jpg", new File(destiny+"/photo" + i + ".jpg"));
            System.out.println("Now: " + i);
        } catch (ArrayIndexOutOfBoundsException e) {
            check = false;
        }
        catch(JCodecException e){
            e.printStackTrace();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        i++;
    }
}

.

Exception in thread "main" java.lang.NullPointerException
at org.jcodec.api.FrameGrab.<init>(FrameGrab.java:59)
at org.jcodec.api.FrameGrab.getFrame(FrameGrab.java:331)
at Pack.Main.Frames(Main.java:22)
at Pack.Main.main(Main.java:77)

Thanks

How to count number of custom objects in list which have same value for one of its attribute

I am programming in java. Say I have an custom object Item

class Item
{
     Integer id;
     BigDecimal itemNumber;
}

I have list of Items.

List<Item> items = new ArrayList<>();

Now, What is best way in java to know, list of Items contain some Items with same value for itemNumber.

How Can I extract the .dat file(contain image) using java API

HMEFContentsExtractor ext = new HMEFContentsExtractor(new File(winmailFilename));

   File dir = new File(directoryName);
   File rtf = new File(dir, "message.rtf");
   if(! dir.exists()) {
       throw new FileNotFoundException("Output directory " + dir.getName() + " not found");
   }
   HMEFMessage msg = new HMEFMessage(new FileInputStream(winmailFilename));
   msg.getAttachments();

Iterating over a hashmap struts 1.x

Sturts 1.x framework. I'm trying to iterate over a hash map. "blockIdCountMap" is the hashmap which is returned by a getter method in "EquipmentCharacteristicFormBean" bean.

Code in jsp page.

<logic:iterate name="EquipmentCharacteristicFormBean" id="blockIdCountMap" >
        <bean:write name="blockIdCountMap" property="key"/>
        <bean:write name="blockIdCountMap" property="value"/>
</logic:iterate>

ERROR:

Aug 4, 2015 5:18:43 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet login threw exception
javax.servlet.jsp.JspException: Cannot create iterator for this collection
    at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:310)
    at org.apache.struts.taglib.nested.logic.NestedIterateTag.doStartTag(NestedIterateTag.java:123)
    at org.apache.jsp.website.equipment.equipmentCharacteristic_jsp._jspService(equipmentCharacteristic_jsp.java:224)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:451)
    at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:451)
    at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:520)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.railsync.command.filter.RequestMonitorFilter.doFilter(RequestMonitorFilter.java:102)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.railsync.command.filter.GZIPFilter.doFilter(GZIPFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:655)

How can I animate my binary tree drawing in Java

I am really struggling with a a project that I am working on. The eventual outcome should be an animation that shows algorithms in AVLTrees. I have managed to display a tree using values input by a user. But I am worried that they I have done it may prevent me being able to animate it. Each time a node is added, the entire tree is re drawn (up to a depth of four at the moment), is there a way (I assume after a lot of "if" statements) do gradually animate the new line added, and then have the new node appear? I apologise in advance if this is the worst code ever seen on here, I"m very new to java and struggling a lot!

    package dissV12;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class AnimateNode implements ActionListener {

    NodePane nodePane = new NodePane();
    JButton jb1, jb2, jb3;  
    JTextField tf;

    public static void main(String[] args) {

        AnimateNode animate = new AnimateNode();

    }

    public AnimateNode() {

        JFrame frame = new JFrame("Version12");     
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());

        JPanel jp1 = new JPanel();      

        tf = new JTextField(3);
        jb1 = new JButton("Search");
        jb2 = new JButton("Insert");
        jb3 = new JButton("Delete");
        jb1.addActionListener(this);
        jb2.addActionListener(this);
        jb3.addActionListener(this);
        frame.add(jp1, BorderLayout.SOUTH);
        jp1.add(tf);
        jp1.add(jb1);
        jp1.add(jb2);
        jp1.add(jb3);

        nodePane.setPreferredSize(new Dimension(1000, 600));
        frame.add(nodePane, BorderLayout.CENTER);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        String input = tf.getText();
        int numbInput = (int) ((Double.parseDouble(input)));

        if (e.getSource() == jb1) {

            tf.setText("");
        }

        if (e.getSource() == jb2) {
            nodePane.insert(numbInput);
            tf.setText("");

        }

        if (e.getSource() == jb3) {

            tf.setText("");

        }

    }

}

This next class is where the drawing takes place. So I assume this is where I put the timer??? Beyond that, I have no idea what I'm doing but feel I have read everything on the internet :/

import java.awt.FontMetrics;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.Timer;


public class NodePane extends JPanel implements ActionListener {

    private Timer t;

    AVLTree12<Integer> tree;
    Node adding;

    public NodePane() {
        tree = new AVLTree12<Integer>();
        adding = null;
        t = new Timer(1000, this);
        t.start();
    }

    public void addingNode(Node n) {
        adding = n;
    }

    public void insert(int n) {
        tree.insert(n);
        tree.updateLevels();        
        Node nd = tree.getNodeSearch(n);
        System.out.println(nd);
        addingNode(nd);
        repaint();
    }

    public void delete(int n){
        if(tree.search(n)){

        }
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2D = (Graphics2D) g.create();
        if (adding != null) {

            Queue<Node> queue = new LinkedList<Node>();
            queue.add(tree.root);

            while (!queue.isEmpty()) {
                Node node = queue.poll();
                int level = node.getLevel();
                if (level == 1) {
                    Point p = paintLevelOne(node, g2D);
                    paintNode(node, p, g2D);
                }

                if (level == 2) {
                    Node parent = node.getParent();
                    if (node.compareTo(parent) > 0) {
                        Point p = paintLevelTwo(node, 2, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);
                    }
                    if (node.compareTo(parent) < 0) {
                        Point p = paintLevelTwo(node, 1, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);
                    }
                }
                if (level == 3) {
                    Node parent = node.getParent();
                    Node gParent = parent.getParent();
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) < 0) {
                        Point p = paintLevelThree(node, 1, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) < 0) {
                        Point p = paintLevelThree(node, 2, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) > 0) {
                        Point p = paintLevelThree(node, 3, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) > 0) {
                        Point p = paintLevelThree(node, 4, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }

                }
                if(level == 4){
                    Node parent = node.getParent();
                    Node gParent = parent.getParent();
                    Node gGParent = gParent.getParent();
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) < 0 && gParent.compareTo(gGParent)<0) {
                        Point p = paintLevelFour(node, 1, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) < 0 && gParent.compareTo(gGParent)<0) {
                        Point p = paintLevelFour(node, 2, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) > 0 && gParent.compareTo(gGParent)<0) {
                        Point p = paintLevelFour(node, 3, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) > 0 && gParent.compareTo(gGParent)<0){
                        Point p = paintLevelFour(node, 4, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) < 0 && gParent.compareTo(gGParent)>0) {
                        Point p = paintLevelFour(node, 5, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) < 0 && gParent.compareTo(gGParent)>0) {
                        Point p = paintLevelFour(node, 6, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) < 0 && parent.compareTo(gParent) > 0 && gParent.compareTo(gGParent)>0) {
                        Point p = paintLevelFour(node, 7, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                    if (node.compareTo(parent) > 0 && parent.compareTo(gParent) > 0 && gParent.compareTo(gGParent)>0){
                        Point p = paintLevelFour(node, 8, g2D);
                        paintLine(node, g2D);
                        paintNode(node, p, g2D);

                    }
                }
                Node left = node.getLeft();
                Node right = node.getRight();
                if (left != null) {
                    queue.add(left);
                }
                if (right != null) {
                    queue.add(right);
                }
            }
        }

    }

    public void paintNode(Node n, Point p, Graphics2D g2d) {

        if (n != null) {

            FontMetrics fm = g2d.getFontMetrics();
            int radius = (fm.getHeight()) * 2;

            Ellipse2D circ = new Ellipse2D.Float(p.x, p.y, radius, radius);
            g2d.draw(circ);
            String text = String.valueOf(n.getData());
            int xTextPos = p.x + ((radius - fm.stringWidth(text)) / 2);
            int yTextPos = p.y
                    + (((radius - fm.getHeight()) / 2) + fm.getAscent());

            g2d.drawString(text, xTextPos, yTextPos);
        }
    }

    public void paintLine(Node n, Graphics2D g2d) {
        FontMetrics fm = g2d.getFontMetrics();
        int radius = (fm.getHeight()) * 2;
        Node parent = n.getParent();
        Point p = parent.getLocation();
        int xPar = p.x + (radius/2);
        int yPar = p.y + radius;
        Point pP = new Point(xPar, yPar);

        Point pc = n.getLocation();
        int xC = pc.x+(radius/2);
        int yC = pc.y;
        Point pC = new Point(xC, yC);
        g2d.draw(new Line2D.Float(pP, pC));

    }

    public Point paintLevelOne(Node n, Graphics2D g2d) {
        FontMetrics fm = g2d.getFontMetrics();
        int radius = (fm.getHeight()) * 2;
        int x = (getWidth() / 2) - (radius / 2);
        int y = radius;
        Point p = new Point(x, y);
        n.setLocation(p);
        return p;
    }

    public Point paintLevelTwo(Node n, int l2, Graphics2D g2d) {
        FontMetrics fm = g2d.getFontMetrics();
        int radius = (fm.getHeight()) * 2;
        int x = (l2 * (getWidth() / 3)) - (radius / 2);
        int y = 3 * radius;
        Point p = new Point(x, y);
        n.setLocation(p);
        return p;
    }

    public Point paintLevelThree(Node n, int l3, Graphics g2d) {
        FontMetrics fm = g2d.getFontMetrics();
        int radius = (fm.getHeight()) * 2;
        int x = (l3 * (getWidth() / 5)) - (radius / 2);
        int y = 5 * radius;
        Point p = new Point(x, y);
        n.setLocation(p);
        return p;
    }

    public Point paintLevelFour(Node n, int l4, Graphics g2d){
        FontMetrics fm = g2d.getFontMetrics();
        int radius = (fm.getHeight()) * 2;
        int x = (l4 * (getWidth() / 9)) - (radius / 2);
        int y = 8 * radius;
        Point p = new Point(x, y);
        n.setLocation(p);
        return p;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO Auto-generated method stub

    }

}

I assume I won't need to show the Node Class and the Tree class.

If anyone can help I would cry much appreciate it :)

Why Heap sort is not considered as a stable sorting alogorithm

In Java Heap sort seems a best sorting algorithm while sorting an array of random numbers according to http://ift.tt/qTnDd2 But still I read that Heap sort is not stable, why so? Which sorting algorithm should be considered best algorithm while sorting an array or random numbers?

Java mail don't return subject

I'm using javamail to rescue mails of inbox. I get all mails from inbox, but the subject(message.getSubject()) return null.

I research in several sites and all proposed solutions not work.

This problem occurs only in the Tomcat6, if a execute even code in java project for main method i get all atributis, include subject. I'm user de SSL protocol (pop3s).

Thanks for help

public void getMails(final String host, final int port, final String user, final String password){

   final Session session = Session.getInstance(System.getProperties(), null);
   final Store store = session.getStore("pop3s");   

   store.connect(host, port, user, password);
   Folder inbox = store.getFolder("INBOX");
   inbox.open(Folder.READ_WRITE);
   int count = inbox.getMessageCount();
   System.out.println(" Count Emails "+count);

   final Message[] messages = inbox.getMessages();                
   for (final Message message : messages) { 
       //This return null
       System.out.print("mail subject: " + message.getSubject() + " send at: " + message.getSentDate());
       //This return body of mail
       System.out.print("mail subject: " + message.getContent().toString());
}

My output for the method Main directly on eclipse:

MessageCount: 4

full name: INBOX

NewMessageCount: 0

getDescription: null

getFileName: null

getMessageNumber: 1

getSize: 2297

getSentDate: Mon Aug 03 17:23:10 BRT 2015

from: Silvano Wojczak silvano.wojczak@softexpertjlle.onmicrosoft.com

Content: javax.mail.internet.MimeMultipart@6769ba97

Content getClass: class javax.mail.internet.MimeMultipart

For log4j in TomCat6:

MessageCount: 4

full name: INBOX

NewMessageCount: 0

getDescription: null

getFileName: null

getMessageNumber: 1

getSize: 6731

getSentDate: null

from: null

Content: javax.mail.internet.MimeMultipart@6769ba97

Content getClass: class javax.mail.internet.MimeMultipart

Trying to add hyperlink to excel cell but result is filepath

I'm trying to add a hyperlink to excel cell using java as follows.

XSSFCreationHelper helper= xssfWorkbook.getCreationHelper();
XSSFHyperlink url_link=helper.createHyperlink(Hyperlink.LINK_URL);
cell.setCellValue("some Text");
url_link.setAddress("www.google.com");
cell.setHyperlink(url_link);

But when I created the excel file, cell contains wrong url, something as follows.

file:///C:/Users/..../www.google.com

What is I'm doing wrong here? Appreciate any help

Jasperreport barcode JRValidationException

I need to create jasperreport with barcode in table column & show when some parameter is true.

   <field name="myField" class="java.lang.String"/>


<frame>
 <reportElement uuid="1fc9fc94-0e14-4b98-9e20-ad68cad679c7" key="myField" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="63" y="0" width="151" height="23" isPrintWhenDetailOverflows="true"/>
                    <box leftPadding="0" rightPadding="0">
                        <pen lineWidth="1.0"/>
                    </box>
                    <componentElement>
                        <reportElement uuid="8b98e4f1-a5ae-4453-bb76-3ee99704c183" key="myField" positionType="Float" x="0" y="2" width="151" height="18" isPrintWhenDetailOverflows="true">
                            <printWhenExpression><![CDATA[$P{needToPrint} == true]]></printWhenExpression>
                        </reportElement>
                        <jr:barbecue xmlns:jr="http://ift.tt/1cl9b3L" xsi:schemaLocation="http://ift.tt/1cl9b3L http://ift.tt/1cl9b3P" type="Code39 (Extended)" drawText="false" checksumRequired="false">
                            <jr:codeExpression><![CDATA[$F{myField}]]></jr:codeExpression>
                        </jr:barbecue>
                </componentElement>
            </frame>

When i try to print it, I have

net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 
     1. Element reaches outside frame width: x=0, width=151, available width=69.

But only if column width on UI less than some value (less, not greater). Frame paddings = 0. I also trying to set x="0" - it doesn't help. In jasper src it fails here:

if (element.getX() + element.getWidth() > avlblWidth)
where int avlblWidth = frame.getWidth() - leftPadding - rightPadding;
element form frame.getElements();

I would be grateful for any help

Cordova PhoneGap upgrade to 5.1.1 from 2.2.0

I have Cordova application which is version 2.2.0. Now I want to upgrade, I have done upgrade part, after upgrading, application images are not display, it came blank screen. even splash screen also not came. Here is my code

Seem problem in my BaseScreen.js. I have given alert & check HomeScreen.js before execute basescreen part, the alert is working. but Basescreen also alert came,

HomeScreen.js

var HomeScreen = BaseScreen
    .extend({
        templateContent : "<ul id='homeBtnsList'>\
        alert("-----HI-Home in---");
                     <li id='playGame'><img src='interface/play-icon@2x.png'><div class='gloss'></div><span>" + language.HOME_PLAY_GAME + "</span></li>\
                     <li id='viewScore'><img src='interface/scoreboard-icon@2x.png'><div class='gloss'></div><span>" + language.HOME_VIEW_SCORE + "</span></li>\
                     <li id='viewRules'><img src='interface/instruction-icon@2x.png'><div class='gloss'></div><span>" + language.HOME_VIEW_RULES + "</span></li>\
                </ul>\
                <div class='copyright'>Copyright &copy; Pearson</div>\
                <div class='about'></div>\
                <div id='footer'>\
                    ",
        headerClass : "head homehead",
        screenClass : "",

        initialize : function() {
            _.bindAll(this, "handleRenderComplete", "handleItemClick", "initScroll", "closeAboutUs", "aboutUsAction");
            BaseScreen.prototype.initialize(this);
            this.bind(AppEvent.RENDER_COMPLETE, this.handleRenderComplete);
            _.extend(this, Backbone.Events);
        },

        render : function() {
            this.element = this.el;
            var divString = BaseScreen.prototype.render(this);
            return divString;
        },

        show : function() {
            this.setScreenReady();
        },

        handleRenderComplete : function() {
            $("#homeBtnsList li", this.obj).bind(AppEvent.CLICK, this.handleItemClick);
            $("div.about", this.obj).bind(AppEvent.CLICK, this.aboutUsAction);

            if(isIOS()) {
                ShareKitPlugin.prototype.logoutFromTwitter();
                ShareKitPlugin.prototype.logoutFromFacebook();
                _.delay(navigator.splashscreen.hide,1000);
            }

        },

        setScreenReady : function() {
            var obj = {
                screenId : this.model.toString()
            };
            this.trigger(AppEvent.SCREEN_READY, obj);
        },

        handleItemClick : function(e) {
            // alert(e.target.nodeName + " : " +
            // e.target.parentNode.nodeName);
            var tar = e.target;
            if (e.target.nodeName.toLowerCase() != "li") {
                tar = e.target.parentNode;
                // return;
            }
            // alert(tar.nodeName + " : " + tar.parentNode.nodeName);
            et = tar;

            e.preventDefault();

            var obj = {};

            id = $(et).attr('id') ? $(et).attr('id') : $(et).find('li')
                    .attr('id');

            switch (id) {
            case "playGame":
                obj.screenId = AppConst.GROUP_SCREEN;
                this.trigger(AppEvent.GOTO_SCREEN, obj);
                return;
            case "viewScore":
                obj.screenId = AppConst.SCORE_HOME_SCREEN;
                this.trigger(AppEvent.GOTO_SCREEN, obj);
                return;
            case "viewRules":
                obj.screenId = AppConst.INSTRUCTION_SCREEN;
                this.trigger(AppEvent.GOTO_SCREEN, obj);
                return;
            default:
                return;
            }
            ;

        },


    initScroll: function(obj){
        utils.log("SCROLL ACTIVE")
        this.iScroll = new iScroll($("#helpContent").get(0), {desktopCompatibility:true});
    },

    aboutUsAction: function(){

        var obj = {};
        obj.screenId = AppConst.ABOUTUS_SCREEN;
        this.trigger(AppEvent.GOTO_SCREEN, obj);

    },

    closeAboutUs: function(){

        $("#helpWrapper #helpContent").html("");
        $('#helpWrapper').hide();
        this.iScroll.destroy();

    },

    destroy : function() {
            utils.log("destroy ", this.model.get('myId'));
            //$("#homeBtnsList li", this.obj).unbind();
            $("div.about", this.obj).unbind();
            this.unbind();
            BaseScreen.prototype.destroy(this);
        }
    })

This is my BaseScreen.js

    var BaseScreen = Backbone.View.extend
({
    templateStart:"<div id='<%=myId%>' class='screen <%=screenClass%>'>\
                        <!--header-->\
                        <div id='header' class='head <%=headerClass%>'>\
                            <!--LEFT BTN-->\
                            <div class='header-left-btn <%=leftBtnClass%>'>\
                                    <span><%=leftLabel%></span>\
                                </div>\
                            <!--TITLE-->\
                            <h1><%=title%></h1>\
                            <!--RIGHT BTN-->\
                            <div class='header-right-btn <%=rightBtnClass%>'>\
                            <%=rightLabel%>\
                                </div>\
                            </div>\
                        <div class='content'>",
    templateContent:"",
    templateClose:"</div></div>",
    element:null,

    render:function(extendedObject)
    {
        var curObj = extendedObject || this;
        //console.log('screen Element: ' + curObj.el.get(0).id)
        var baseScreenModel = {};

        if(curObj.model){
            baseScreenModel = curObj.model.toJSON();
        }

        var thatId = baseScreenModel.myId;
        var template = _.template(curObj.templateStart + curObj.templateContent + curObj.templateClose);
        var data = _.extend(baseScreenModel, {
            screenClass: curObj.screenClass,
            headerClass: curObj.headerClass
        });

        // curObj.element.append(template(baseScreenModel));
        curObj.element.append(template(baseScreenModel));

        // //console.log(template(baseScreenModel))
        // //console.log(" >>>> " + thatId)
        //var screen = curObj.element.find("#" + thatId);

        var screen = $("#" + thatId);
        ////console.log("appended node " + screen.length);

        if(screen.length <= 0){
            ////console.log("length is zero")
            //console.log("delay .....");
            _.delay(BaseScreen.prototype.render, 1000, curObj);
            return curObj.element;;
        }

        ////console.log("appended node == " + screen.html());

        var sClass = curObj.screenClass || "";
        var hClass = curObj.headerClass || "";

        //screen.find(".screen").addClass(sClass);
        //screen.find("#header").addClass(hClass);

        $(screen).addClass(sClass);
        $("#header", $(screen)).addClass(hClass);



        // screen.find("#leftElement").bind(AppEvent.CLICK, curObj.handleButtonClick);
        // screen.find("#rightElement").bind(AppEvent.CLICK, curObj.handleButtonClick);
        $("#leftElement", $(screen)).bind(AppEvent.CLICK, function(e){
            ////console.log("#leftElement ", e.target);
            that.trigger(AppEvent.HEADER_ITEM_CLICKED, AppConst.HEADER_LEFT_ELEMENT);
        });
        $("#rightElement", $(screen)).bind(AppEvent.CLICK, function(e){that.trigger(AppEvent.HEADER_ITEM_CLICKED, e.target.id);});
        curObj.trigger(AppEvent.RENDER_COMPLETE);
        return curObj.element;      
    },

    initialize:function(extendedObject)     //only called when extending BaseScreen
    {
        var curObj = extendedObject||this;
        //_.bindAll(curObj, "handleButtonClick");
        _.extend(curObj, Backbone.Events);
    },

    handleButtonClick:function(e)
    {
        this.trigger("buttonClick", e.target.id);
    },

    destroy:function(extendedObject) {
        var that = extendedObject||this;
        var thatId = that.model.get('myId');
        var screen = that.element.find("#" + thatId);
        screen.find("#leftElement").unbind();
        screen.find("#rightElement").unbind();      
        //debug.log("destroy base screen for " + thatId);
        screen.remove();
    },

    handleHeaderLeftClicked:function() {
        //console.log("left clicked", this);        
        if(DEVICE_TYPE == DEVICE_ANDROID || DEVICE_TYPE == DEVICE_ANDROID_TAB || DEVICE_TYPE == DEVICE_PC) {
            Functions.prototype.exit();
           }
    }

})

index.html:

    <!DOCTYPE html>
<html manifest="appcache.manifest">
    <head>
        <meta name="apple-mobile-web-app-capable" content="yes" >
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" >
        <title>My Application</title>

        <link href="css/global.css" media="all" rel="stylesheet" type="text/css">


        <script src="com/external/underscore.js" ></script>
        <script src="com/external/iscroll.js" ></script>

        <script src="com/external/zepto.js" ></script>
        <script src="com/external/ajax.js" ></script>
        <script src="com/external/touch.js" ></script>
        <script src="com/external/event.js" ></script>
        <script src="com/external/effects.js" ></script>
        <script src="com/external/detect.js" ></script>
        <script src="com/external/jsOAuth-1.3.1.js" ></script>
        <script src="com/external/json2.js" ></script>
        <script src="com/external/jsPatch.js" ></script>
        <script src="com/external/backbone.js" ></script>

        <script src="com/imfinity/comp/webkitdragdrop.js" ></script>
        <script src="com/imfinity/utils/jsExtended.js" ></script>
        <script src="com/imfinity/utils/stopwatch.js" ></script>

        <script src="com/imfinity/screen/BaseScreenVO.js" ></script>
        <script src="com/imfinity/screen/BaseScreen.js" ></script>


        <script src="com/sns/init.js"></script>

        <script src="com/sns/jsonParser.js" ></script>
        <script src="com/sns/utilities.js" ></script>
        <script src="com/sns/language.js" ></script>
        <script src="com/sns/AppConst.js" ></script>
        <script src="com/sns/services.js" ></script>
        <script src="com/sns/db.js" ></script>
        <script src="com/sns/AppEvent.js" ></script>
        <script src="com/sns/controller/main.js" ></script>

        <script src="com/sns/model/HomeScreenVO.js" ></script>
        <script src="com/sns/view/HomeScreen.js" ></script>

        <script src="com/sns/view/helpScreenView.js" ></script>
        <script src="com/sns/model/helpScreenVO.js" ></script>

        <script src="com/sns/view/aboutScreenView.js" ></script>
        <script src="com/sns/model/aboutScreenVO.js" ></script>

        <script src="com/sns/model/scoreHomeScreenVO.js" ></script>
        <script src="com/sns/view/scoreHomeScreenView.js" ></script>


        <script src="com/sns/view/resultsScreenView.js" ></script>
        <script src="com/sns/model/resultScreenVO.js" ></script>

        <script src="com/sns/view/activity/reorderingView.js" ></script>
        <script src="com/sns/view/activity/tapNplaceView.js" ></script>



        <!--script src="com/sns/sns-minified.js"></script-->


    </head>
    <body onload="onLoad()"  style="overflow: hidden;">
        <div class='insOverlay'>
            <div id='instructionsWrapper'><img/>
            </div>
        </div>
        <div id="overlay">
            <div id="preloader"></div>
            <div id="genericHUD" >
                <div id='HUDcontent'><img src='interface/load.png'>
                </div>
            </div>
        </div>
        <div id="toast" class="Overlay_toast" style="display: none;">
            <div class="toast_message"></div>
        </div>

        <div id='helpWrapper' class="overlay darkShade" style="display: none;">
            <div class="helpWindow">
                <span id='helpClose' class="close-pop-up"></span>
                <h1>Help</h1>
                <div id='helpContent' class="helpContent"></div>
            </div>
        </div>

        <div id="banner" class="overlay darkShade"></div>

        <div class="modalOverlay" style="display: none;">
            <div class="modalWindow">
                <span class="close-pop-up"></span>
                <h1 class="whiteHeading">Share</h1>
                <p id='email' class="share-btn share-with-friend">

                </p>
                <p id='twitter' class="share-btn share-on-twitter">

                </p>
                <p id='facebook' class="share-btn share-on-facebook">

                </p>
            </div>
        </div>

        <div class="editTextOverlay">
            <div class='editTextPopup'>
                <div class="editTextHeader">
                    <span id="leftBtn" class="editTextButton">Cancel</span>
                    <span id="rightBtn"  class="editTextButton"></span>
                </div>
                <textarea rows="4" autocomplete="off" spellcheck="false" style="outline: none;" maxlength="140"></textarea>
            </div>
        </div>

        <div class="normalOverlay" id="confirmBox">
            <div class='normalTextPopup'>
            <h2>Confirm</h2>
                <div id="confirmMsg">
                    message
                </div>
                <div>
                    <span id="leftBtn" class="normalTextButton"></span>
                    <span id="rightBtn"  class="normalTextButton"></span>
                </div>

            </div>
        </div>

        <div id="wrap" >
            <div id="screens" >
                <div id='questionPlayer' class='screen'></div>
            </div>

        </div>
    </body>
</html>

cofig : res/xml/config.xml

    <?xml version='1.0' encoding='utf-8'?>
<cordova>
    <access origin="http://127.0.0.1*" />
    <access origin=".*" />
    <log level="DEBUG" />
    <preference name="useBrowserHistory" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="SplashScreen" value="splash" />
    <preference name="SplashScreenDelay" value="10000" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <plugins>
        <plugin name="App" value="org.apache.cordova.App" />
        <plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />
        <plugin name="Device" value="org.apache.cordova.Device" />
        <plugin name="Accelerometer" value="org.apache.cordova.AccelListener" />
        <plugin name="Compass" value="org.apache.cordova.CompassListener" />
        <plugin name="Media" value="org.apache.cordova.AudioHandler" />
        <plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
        <plugin name="Contacts" value="org.apache.cordova.ContactManager" />
        <plugin name="File" value="org.apache.cordova.FileUtils" />
        <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
        <plugin name="Notification" value="org.apache.cordova.Notification" />
        <plugin name="Storage" value="org.apache.cordova.Storage" />
        <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer" />
        <plugin name="Capture" value="org.apache.cordova.Capture" />
        <plugin name="Battery" value="org.apache.cordova.BatteryListener" />
        <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen" />
        <plugin name="Echo" value="org.apache.cordova.Echo" />
        <plugin name="Globalization" value="org.apache.cordova.Globalization" />
        <plugin name="SQLitePlugin" value="com.phonegap.plugins.SQLitePlugin" />
        <plugin name="FlurryPlugin" value="com.phonegap.plugins.Flurry" />
        <plugin name="AndroidUtilsPlugin" value="com.phonegap.plugins.AndroidUtilsPlugin" />
        <plugin name="ChildBrowserPlugin" value="com.phonegap.plugins.ChildBrowserPlugin" />
    </plugins>
    <feature name="File">
        <param name="android-package" value="org.apache.cordova.file.FileUtils" />
        <param name="onload" value="true" />
    </feature>
</cordova>

Please let me know what is an issue. After upgrading only , I am facing this isssue, could you please guide me about this.

In Spring can you give an example where isolation level is used along with propagation?

I want to perform isolation level along with propagation How I can achieve it. Suppose inside RequiresNew I want to do READ_COMMITTED in DB.

Is Declaring @Transactional(propagation = Propagation.REQUIRED,isolation=Isolation.READ_COMMITTED) valid?

If yes,How it will internally work?

Creating only @Transactional(isolation=Isolation.READ_COMMITTED) will create a new transaction? If yes, will it be a new transaction every time behaving like RequiresNew?

I have multiple select and join SQL queries and I want to return a single result set in MySQL

SELECT COUNT(*) FROM SYSTEM.PARTITIONEDTABLES where schema=? and TABLENAME=?

SELECT PC.SCHEMA, PC.TABLENAME, PC.PARTITIONNAME, PC.ISDEFAULT, PC.VALUE,PT.PARTITIONTYPE, PT.PARTITIONINGCOLUMN, PT.DEFAULTPARTITION, PI.STORAGEGROUP FROM SYSTEM.PARTITIONCRITERIA PC JOIN SYSTEM.PARTITIONEDTABLES PT ON PC.TABLENAME=PT.TABLENAME AND PC.SCHEMA=PT.SCHEMA JOIN SYSTEM.PARTITIONIDS PI ON PC.TABLENAME=PI.TABLENAME AND PC.SCHEMA=PI.SCHEMA AND PC.PARTITIONNAME=PI.PARTITIONNAME WHERE PC.SCHEMA='' AND PT.TABLENAME=''

What are the telegram-api AbsApiState contracts (How should I implement it's methods?)

I am trying to write a telegram client with ex3ndr/telegram-api, but I don't know how to implement that correctly. Anybody knows how these methods are supposed to work ?

Aspectj default constructor pointcut

Im working with some AspectJ code and i want to catch all the executions for none private pointcuts.

@Pointcut("execution(public * *(..))")//Public
public void publicMethod(){};
@Pointcut("execution(protected * *(..))"//Protected
public void protectedMethod(){}

@Pointcut("@annotation(mypackage.name.annotationName")
public void annotationPointcut(){}

@Around("annotationPointcut() && (protectedMethod() || publicMethod())")
public Object test(){ System.out.println("Should not print private"); }

I read about using ! (not) but could not get it to work. Something like

@Pointcut("!execution(private * *(..))"

But without getting it to work.

I could not find a modifier name for default class modifier in the aspectJ, have I missed it or do i need to try and solve it by using ! not sign in some sort of way?

Regards a new dev that are learning aspectJ

Android nullpointer Screenslider (view pager)

I have downloaded the demo screen slider from android (http://ift.tt/1AtG7DO). I've tried to put this in my own project but i get this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{http://ift.tt/1N74MTn}: java.lang.NullPointerException
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
        at android.app.ActivityThread.access$900(ActivityThread.java:169)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5479)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
        at com.pws.test.demo.D_D_RondleidingMenu.SetupUitgebreideRondleidingButton(D_D_RondleidingMenu.java:24)
        at com.pws.test.demo.D_D_RondleidingMenu.onCreate(D_D_RondleidingMenu.java:17)
        at android.app.Activity.performCreate(Activity.java:5451)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:169)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5479)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)

This is my code:

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
/**
 * Demonstrates a "screen-slide" animation using a {@link ViewPager}. Because {@link ViewPager}
 * automatically plays such an animation when calling {@link ViewPager#setCurrentItem(int)}, there
 * isn't any animation-specific code in this sample.
 *
 * <p>This sample shows a "next" button that advances the user to the next step in a wizard,
 * animating the current screen out (to the left) and the next screen in (from the right). The
 * reverse animation is played when the user presses the "previous" button.</p>
 *
 * @see
 */
public class E_D_Uitgebreid extends FragmentActivity {
    /**
     * The number of pages (wizard steps) to show in this demo.
     */
    private static final int NUM_PAGES = 3;

    /**
     * The pager widget, which handles animation and allows swiping horizontally to access previous
     * and next wizard steps.
     */
    private ViewPager mPager;

    /**
     * The pager adapter, which provides the pages to the view pager widget.
     */
    private PagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_e__d__uitgebreid__fragment);

        // Instantiate a ViewPager and a PagerAdapter.
        mPager = (ViewPager) findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                // When changing pages, reset the action bar actions since they are dependent
                // on which page is currently active. An alternative approach is to have each
                // fragment expose actions itself (rather than the activity exposing actions),
                // but for simplicity, the activity provides the actions in this sample.
                invalidateOptionsMenu();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.menu_e__d__uitgebreid, menu);

        menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

        // Add either a "next" or "finish" button to the action bar, depending on which page
        // is currently selected.
        MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
                (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1)
                        ? R.string.action_finish
                        : R.string.action_next);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                // Navigate "up" the demo structure to the launchpad activity.
                // See http://ift.tt/HxQCh0 for more.
                NavUtils.navigateUpTo(this, new Intent(this, D_D_RondleidingMenu.class));
                return true;

            case R.id.action_previous:
                // Go to the previous step in the wizard. If there is no previous step,
                // setCurrentItem will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
                return true;

            case R.id.action_next:
                // Advance to the next step in the wizard. If there is no next step, setCurrentItem
                // will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                return true;
        }

        return super.onOptionsItemSelected(item);
    }


    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
        public ScreenSlidePagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return E_D_Uitgebreid_Fragment.create(position);
        }

        @Override
        public int getCount() {
            return NUM_PAGES;
        }
    }
}

And the fragment:

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * A fragment representing a single step in a wizard. The fragment shows a dummy title indicating
 * the page number, along with some dummy text.
 *
 * <p>This class is used by the  and {@link
 * } samples.</p>
 */

public class E_D_Uitgebreid_Fragment extends Fragment {
    /**
     * The argument key for the page number this fragment represents.
     */
    public static final String ARG_PAGE = "page";

    /**
     * The fragment's page number, which is set to the argument value for {@link #ARG_PAGE}.
     */
    private int mPageNumber;

    /**
     * Factory method for this fragment class. Constructs a new fragment for the given page number.
     */
    public static E_D_Uitgebreid_Fragment create(int pageNumber) {
       E_D_Uitgebreid_Fragment fragment = new E_D_Uitgebreid_Fragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PAGE, pageNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public E_D_Uitgebreid_Fragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPageNumber = getArguments().getInt(ARG_PAGE);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout containing a title and body text.
        ViewGroup rootView = (ViewGroup) inflater
                .inflate(R.layout.activity_e__d__uitgebreid__fragment, container, false);

        // Set the title view to show the page number.
        ((TextView) rootView.findViewById(android.R.id.text1)).setText(
                Articles.paginatitel[mPageNumber]);

        ((TextView) rootView.findViewById(android.R.id.text2)).setText(
                Articles.paginainhoud[mPageNumber]);

        ((ImageView) rootView.findViewById(android.R.id.background)).setImageResource(Articles.afbeelding[mPageNumber]);

        return rootView;
    }




    /**
     * Returns the page number represented by this fragment object.
     */
    public int getPageNumber() {
        return mPageNumber;
    }
}

I've already changed this, but this didn't work:

private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
    public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
        super(fm);
    }

and this:

@Override
    public android.support.v4.app.Fragment getItem(int position) {
        return E_D_Uitgebreid_Fragment.create(position);
    }

How to use ical rdate in java to create meeting invite for multiple days using date

I want to create meeting invite for multiple days for different time slot on each day in java. however i don't want to use rrule because it doesn't support different time slot for each day.

I get some info about rdate to support multiple date with different time slot but didn't get full source code.I tried different combination but it doesn't work.

can anyone help me about this ?

JNLP error opening on localhost

Hello I created a JAVAFX application and upload the Java Websart package on my localhost server but when I was opening the app it does have an error. I already added the url to exception list on configure java security. Can you help me what this errors are? When I run the JAR file that comes along with the JNLP file it execute perfectly. I think its something related to file permission?

Java Plug-in 11.51.2.16
Using JRE version 1.8.0_51-b16 Java HotSpot(TM) Client VM
User home directory = C:\Users\yves
----------------------------------------------------
java.lang.ExceptionInInitializerError
    at Main.loadLoginScene(Unknown Source)
    at Main.start(Unknown Source)
    at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/27634459.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$44/31215714.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$34/10055096.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at Constants.<clinit>(Unknown Source)
    ... 13 more
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.ExceptionInInitializerError
    at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/27634459.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$44/31215714.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
    at com.sun.glass.ui.win.WinApplication$$Lambda$34/10055096.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
    at Main.loadLoginScene(Unknown Source)
    at Main.start(Unknown Source)
    ... 11 more
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.dir" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at Constants.<clinit>(Unknown Source)
    ... 13 more

Could not autowire field performing Junit Tests in Spring 3.2.8 & junit 4.4

Having this class, I am havin to perform some tests with the library junit 4.4. without success

public class GeolocationServiceTest extends AbstractAnnotationAwareTransactionalTests {

        private static final String GEOJSON_FILE =  "geojson_demo.geojson";

        private static final String GEOJSON_FILE2 =  "geojson_ecat.geojson";        

        private static final String ADDRESS  =  "Avenue+de+Beaulieu+25+PARIS";

        private static final String ADDRESS2 =  "Rue Jourdan+1+-+PARIS";    


        private static final String[] CONFIG_LOCATIONS = new String[] {
            "classpath:com/devices/testServiceContext.xml",
            "classpath:com/devices/testApplicationContext.xml",      "classpath:com/devices/testDatabaseMessageSource.xml",     "classpath:com/devices/propertyeditorsContext.xml" };


        @Autowired
        private CompanyDao companyDao;

        @Autowired
        private GeolocationService geolocationService;

    ...
    }

I got this strange error saying that is not posible the injection of a bean, but this bean exists in the file testServiceContext.xml so i don't understand it at all.

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.devices.services.GeolocationServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.devices.services.geolocation.GeolocationService com.devices.services.GeolocationServiceTest.geolocationService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.devices.services.geolocation.GeolocationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:376)
        at org.springframework.test.AbstractDependencyInjectionSpringContextTests.injectDependencies(AbstractDependencyInjectionSpringContextTests.java:210)
        at org.springframework.test.AbstractDependencyInjectionSpringContextTests.prepareTestInstance(AbstractDependencyInjectionSpringContextTests.java:184)
        at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:103)
        at junit.framework.TestCase.runBare(TestCase.java:139)
        at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:79)
        at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:74)
        at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:179)
        at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:287)
        at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:258)
        at org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:176)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:255)
        at junit.framework.TestSuite.run(TestSuite.java:250)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.devices.services.geolocation.GeolocationService com.devices.services.GeolocationServiceTest.geolocationService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.devices.services.geolocation.GeolocationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
        ... 25 more
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.devices.services.geolocation.GeolocationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
        ... 27 more


here you can see the file testServiceContext.xml:

 <!-- Scan for services -->    
    <context:component-scan base-package="com.devices.services.impl" />
    <context:component-scan base-package="com.devices.services.geolocation" />

and the class seems to be well declared

package com.devices.services.geolocation

@Service(value = "geolocationService")
public interface GeolocationService {
....    
}

Trying to upload aa file to Google Nearline Storage from a Java program using the Java API, but I'm getting a Forbidden error

This is my code:

        File file = new File("text.txt");

        InputStream inputStream = new FileInputStream(file);  // object data, e.g., FileInputStream


        long byteCount = inputStream.available();  // size of input stream

        InputStreamContent mediaContent = new InputStreamContent("application/octet-stream", inputStream);
        // Knowing the stream length allows server-side optimization, and client-side progress
        // reporting with a MediaHttpUploaderProgressListener.
        mediaContent.setLength(byteCount);

        StorageObject objectMetadata = null;

        Storage.Objects.Insert insertObject = client.objects().insert("mybucket", objectMetadata, 
           mediaContent);
        insertObject.setName("text");

And this is the error message:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Forbidden",
    "reason" : "forbidden"
  } ],
  "message" : "Forbidden"
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:423)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
    at StorageSample.main(StorageSample.java:194)
And I have "isOwner" as my permission.

According to: http://ift.tt/1MJA59N

The error is because "The requested operation is forbidden and cannot be completed."

So how can I overcome this and upload the file using a Java program.

Thanks in advance.

Why has ArrayList add E and remove Object [duplicate]

This question already has an answer here:

For ArrayList we have:

public boolean add(E e) {

but for remove we have:

public boolean remove(Object o) {

Why isn't it?:

public boolean remove(E e) {

how to handle this error "java.lang.NoSuchFieldError: INSTANCE" in EXCELSIOR JET?

When I run my project in eclipse it works fine but when I want to make an exe of it via EXCELSIOR JET it gives this error!: I read some links but most of them where in a format like:

java.lang.NoSuchFieldError: INSTANCE at org.apache.http.impl.io.DefaultHttpRequestWriterFactory

I mean INSTANCE is referring to apache http or something and that was because some jar files make conflict, but the error my project gives, is referring to one of my Project and I don't know what is wrong.

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchFieldError: INSTANCE
    at myproject.diaggui.toolbar.Toolbar.<init>(Unknown Source)
    at myproject.diaggui.toolbar.Toolbar.init$_aroundBody0(Unknown Source)
    at myproject.diaggui.toolbar.Toolbar.init$_aroundBody1$advice(Unknown Source)
    at myproject.diaggui.toolbar.Toolbar.<clinit>(Unknown Source)
    at myproject.diaggui.IDiagMainForm.<init>(Unknown Source)
    at myproject.diaggui.IDiagMainForm.<clinit>(Unknown Source)
    at myproject.kavosh.SelectionListFrame$3.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

This is my Toolbar class:

public class Toolbar extends JPanel {

    //private static final long serialVersionUID = 1L;

    public static final Toolbar INSTANCE = new Toolbar();

    static int i = 0;

    public Toolbar() {
        setVisible(false);
        setBorder(BorderFactory.createLineBorder(SystemColor.inactiveCaptionBorder, 2));
        setLayout(new FillLayout());
        VarEditor zine = VarEditor.INSTANCE;
        add(zine.getComponent());   
//      addComponentListener(new ComponentAdapter() {
//          @Override
//          public void componentHidden(ComponentEvent e) {
//              CommandBar.INSTANCE.doLayout();
//              //MainForm.getInstance().update(MainForm.getInstance().getGraphics());
//          }
//      });
    }

    @Override
    public int getHeight() {
        return 50;
    }   
}

And this is the class VarEditor:

public class VarEditor {
    // msh1001

    private final class SliderUIExtension extends SliderUI {
    }

    public static VarEditor INSTANCE = new VarEditor();
    DecimalFormat df = new DecimalFormat("#.#");

    private Box box = new Box(BoxLayout.LINE_AXIS);
    private JLabel label = new JLabel("Engine Speed:");


    private JSpinner spinner = new JSpinner();
    // private static double value = 0;
    private static double step = 1;
    private static double max = Double.MAX_VALUE;
    private static double min = Double.MIN_VALUE;
    private static double previousValue = 0;

    boolean inEvent = false;
    boolean dragged = false;
    // private JSlider slider = new JSlider(SwingConstants.HORIZONTAL);

    // //msh

    // private JSliderDouble jsliderdouble = new
    // JSliderDouble(0,0,0,10,10,false);


    private JSliderDouble jsliderdouble;

    // = new JSliderDouble(JSlider.HORIZONTAL,0, min, max, 100, false);



    public VarEditor() {



        box.add(Box.createHorizontalStrut(10));
        label.setFont(CommonUtil.createDefaultUiFont());
        label.setPreferredSize(new Dimension(200, 100));
        box.add(label);


        box.add(Box.createHorizontalStrut(10));


        setSize(spinner, 125, 35);
        spinner.setFont(CommonUtil.createDefaultUiFont());
        box.add(spinner);


        spinner.setEnabled(true);


        box.add(Box.createHorizontalStrut(10));



    }

    private void setComponentListener() {

        jsliderdouble.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                if (!inEvent) {
                    inEvent = true;




                    double value = jsliderdouble.getFloatValue();


                    previousValue = Double.parseDouble(spinner.getValue()
                            .toString());


                    int zarib = (int) ((value - previousValue) / step);
                    double newValue = previousValue + zarib * step;

                    newValue = Double.valueOf(df.format(newValue));




                    // newValue = Math.floor(newValue * 10) / 10;

                    // System.err.println(" in jslider "+ newValue);

                    spinner.setValue(newValue);
                    jsliderdouble.setToolTipText(String.valueOf(newValue));
                    // jsliderdouble.repaint();
                    // jsliderdouble.revalidate();
                    // spinner.setValue(value);

                    // slider.setToolTipText(String.valueOf(slider.getValue()));
                    inEvent = false;


                }

            }
        });

        jsliderdouble.addMouseListener(new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent e) {
                dragged = false;
                // System.out.println("mouse Released."+dragged);
            }

            @Override
            public void mousePressed(MouseEvent e) {
                dragged = true;
                // System.out.println("mouse Pressed."+dragged);
            }

            @Override
            public void mouseExited(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {

            }
        });


        spinner.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                if (!inEvent) {
                    inEvent = true;
                    // slider.setValue((Integer)spinner.getValue());
                    // slider.setToolTipText(String.valueOf(slider.getValue()));


                    // //msh

                    double value = Double.parseDouble(spinner.getValue()
                            .toString());

                    // System.err.println(" in spinner getValue "+ value);


                    // value = Math.floor(value * 10) / 10;
                    value = Double.valueOf(df.format(value));

                    // System.err.println(" in spinner "+value);

                    jsliderdouble.setFloatValue(value);

                    jsliderdouble.setToolTipText(String.valueOf(value));
                    inEvent = false;

                }
            }
        });
    }


    private void setSize(Component c, int w, int h) {
        Dimension d = new Dimension(w, h);
        c.setSize(d);
        c.setPreferredSize(d);
        c.setMaximumSize(d);
        c.setMinimumSize(d);
    }


    Component getComponent() {
        return box;
    }


    public double getValue() {

        // System.err.println(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,");
        // return value;
        double currentValue = Double.parseDouble(String.valueOf(INSTANCE.spinner.getValue()));
          currentValue = Double.valueOf(df.format(currentValue));
        // currentValue = Math.floor(currentValue * 10) / 10;
        System.out.println(currentValue);
        // System.err.println(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,");

        return currentValue;
    }

    public boolean isDragged() {

        return dragged;
    }


    public void setBounds(String name, double min1, double max1, double step1,
            double value1) {


        // msh
        double value = Double.valueOf(df.format(value1));


        if (value < min1)
            value = Double.valueOf(df.format(min1));
        if (value>max1)
            value = Double.valueOf(df.format(max1));


        if ((jsliderdouble == null) || (max != max1) || (min != min1)
                || (step != step1)) {


        //  System.out.println(" in setBoundsssssssssssss" + value1);
            if (jsliderdouble != null)
                box.remove(jsliderdouble);


            max = Double.valueOf(df.format(max1));
            min = Double.valueOf(df.format(min1));

            // value = min;

            step = Double.valueOf(df.format(step1));
            // previousValue = value;

            jsliderdouble = new JSliderDouble(JSlider.HORIZONTAL, value, min,
                    max, Integer.MAX_VALUE, false);
jsliderdouble.setFont(jsliderdouble.getFont().deriveFont(15f));
            jsliderdouble.setFocusable(false);
            jsliderdouble.setOpaque(true);
            jsliderdouble.setForeground(Color.BLUE);

            jsliderdouble.setFloatMaximum(max);
            jsliderdouble.setFloatMinimum(min);

            Hashtable labelTable = new Hashtable();


            int numSlid = (int) ((max - min) / step);
            double pLabel = min;

            double tmp = min;
            double ss = (step * Integer.MAX_VALUE) / (max - min);

            if (numSlid >= 400)
            {
                for (int i = 0; i <= numSlid; i++) {

                    if (i % 20 == 0) {
                        pLabel = min + (i) * step;
                        tmp = i * ss;

                        labelTable.put(new Integer(((int) tmp)), new JLabel(""+ Math.floor(pLabel * 10) / 10));

                    }
                }
                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }
            }

            if (numSlid >= 300 && numSlid > 400) {
                for (int i = 0; i <= numSlid; i++) {



                    if (i % 16 == 0) {
                        pLabel = min + (i) * step;
                        tmp = i * ss;

                        labelTable.put(new Integer((int) tmp), new JLabel(""+ Math.floor(pLabel * 10) / 10));

                    }
                }
                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }
            } else if (numSlid >= 200 && numSlid < 300) {
                for (int i = 0; i <= numSlid; i++) {

                    if (i % 12 == 0) {
                        pLabel = min + (i) * step;
                        tmp = i * ss;

                        labelTable.put(new Integer((int) tmp), new JLabel(""+ Math.floor(pLabel * 10) / 10));

                    }
                }

                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }

            } else if (numSlid >= 100 && numSlid < 200) {

                for (int i = 0; i <= numSlid; i++) {

                    if (i % 8 == 0) {
                        pLabel = min + (i) * step;

                        tmp = i * ss;

                        labelTable.put(new Integer(((int) tmp)), new JLabel(""+ Math.floor(pLabel * 10) / 10));


                    }
                }

                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }
            }


            else if (numSlid >= 45 && numSlid < 100) {

                for (int i = 0; i <= numSlid; i++) {

                    if (i % 4 == 0) {
                        pLabel = min + (i) * step;
                        tmp = i * ss;


                        labelTable.put(new Integer(((int) tmp)), new JLabel(""+ Math.floor(pLabel * 10) / 10));

                    }


                }
                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }

            } else if (numSlid > 25 && numSlid < 45) {

                for (int i = 0; i <= numSlid; i++) {

                    if (i % 2 == 0) {
                        pLabel = min + (i) * step;
                        tmp = (ss * i);

                        labelTable.put(new Integer(((int) tmp)), new JLabel(""+ Math.floor(pLabel * 10) / 10));

                    }
                }
                if (tmp != (numSlid * ss)) {
                    if (!((numSlid * step - pLabel) <= step))
                        labelTable.put(new Integer(((int) (numSlid * ss))),new JLabel("" + (int) (numSlid * step)));
                }
            } else {

                for (int i = 0; i <= numSlid; i++) {


                    // double newPoint = (double)(Integer.MAX_VALUE/numSlid);
                    // newPoint = newPoint * i ;

                    labelTable.put(new Integer(((int) tmp)), new JLabel(""+ Math.floor(pLabel * 10) / 10));
                    tmp += ss;


                    pLabel += step;

                }

            }

            jsliderdouble.setLabelTable(labelTable);


            jsliderdouble.setPaintLabels(true);
            jsliderdouble.setPaintTrack(true);


        jsliderdouble.setVisible(true); 

            // jsliderdouble.setVisible(true);

            label.setText(name);


            label.setToolTipText(name);


            spinner.setModel(new SpinnerNumberModel(value, min, max, step));

            box.add(jsliderdouble);
            // box.repaint();
            // box.validate();

        }

        spinner.setValue(value);
        jsliderdouble.setFloatValue(value);
        setComponentListener();
            box.repaint();
        box.validate();



    }

    public double getMin() {
        double floatMinimum = INSTANCE.jsliderdouble.getFloatMinimum() ;

        floatMinimum = Double.valueOf(df.format(floatMinimum));
        return floatMinimum;

    }


    public double getMax() {
        double floatMaximum = INSTANCE.jsliderdouble.getFloatMaximum() ;

        floatMaximum = Double.valueOf(df.format(floatMaximum));
        return floatMaximum;

    }
}

This is my lib folder:

enter image description here

enter image description here

These are information I thought could be useful, if any more information you need to help please ask.