问:
Android throwing up Error using jtwitter
I am trying to write a twitter application on Android target 2.2 (using some sample code that I found on the net and using Marko Gargenta's O'Reilly text). I am stuck with the problem as in the log below. The source code is given first followed by the log. Any idea what's going wrong here ? Also does anyone have or can point to a sample jtwitter code working on Android.

Thanks,
Ravi

```<code>protected String doInBackground(String... statuses) {
  try {

         //Autho information
         /*OAuthSignpostClient oauthclient = new OAuthSignpostClient(cons_key,
           cons_secret, access_token, access_secret);*/

         OAuthSignpostClient oauthclient = new OAuthSignpostClient(access_token, access_secret,"oob");

         //***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
         twitter = new Twitter(mytwitterusername, oauthclient);
         //twitter.setAPIRootUrl("http://learningandroid.status.net/api");

   //***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
   Log.i(Logtag, "Status currently is " + statuses[0]);

   Twitter.Status status = twitter.updateStatus(statuses[0]);
   //return status.text;
   return statuses[0];
  } catch (TwitterException e) {
   Log.e(Logtag, e.toString());
   e.printStackTrace();
   return "Failed to post to Twitter";
  }
</code>```

}

Log file:

```<code>E/dalvikvm(  719): Could not find method javax.swing.JOptionPane.showInputDialog, referenced from method winterwell.jtwi
tter.OAuthSignpostClient.askUser
W/dalvikvm(  719): VFY: unable to resolve static method 443: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Objec
t;)Ljava/lang/String;
W/dalvikvm(  719): VFY:  rejecting opcode 0x71 at 0x0000
W/dalvikvm(  719): VFY:  rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/Strin
g;
W/dalvikvm(  719): Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
W/dalvikvm(  719): threadid=17: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime(  719): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime(  719): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(  719):        at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:234)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:258)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask.run(FutureTask.java:122)
E/AndroidRuntime(  719):        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
E/AndroidRuntime(  719):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
E/AndroidRuntime(  719):        at java.lang.Thread.run(Thread.java:1058)
E/AndroidRuntime(  719): Caused by: java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
E/AndroidRuntime(  719):        at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:81)
E/AndroidRuntime(  719):        at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:1)
E/AndroidRuntime(  719):        at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
E/AndroidRuntime(  719):        ... 4 more
I/Process (  585): Sending signal. PID: 719 SIG: 3
I/dalvikvm(  719): threadid=7: reacting to signal 3
I/dalvikvm(  719): Wrote stack trace to '/data/anr/traces.txt'
----
</code>```

答: Might be worth looking at using the Twitter4J library as an alternative. I've had no issues using it within an Android application.</p>

Body:
I am trying to write a twitter application on Android target 2.2 (using some sample code that I found on the net and using Marko Gargenta's O'Reilly text). I am stuck with the problem as in the log below. The source code is given first followed by the log. Any idea what's going wrong here ? Also does anyone have or can point to a sample jtwitter code working on Android.

Thanks,
Ravi

protected String doInBackground(String... statuses) {
  try {

         //Autho information
         /*OAuthSignpostClient oauthclient = new OAuthSignpostClient(cons_key,
           cons_secret, access_token, access_secret);*/

         OAuthSignpostClient oauthclient = new OAuthSignpostClient(access_token, access_secret,"oob");

         //***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
         twitter = new Twitter(mytwitterusername, oauthclient);
         //twitter.setAPIRootUrl("http://learningandroid.status.net/api");

   //***POSTING TO TWITTER CURRENTLY DOES NOT WORK WITH THIS INTERFACE
   Log.i(Logtag, "Status currently is " + statuses[0]);

   Twitter.Status status = twitter.updateStatus(statuses[0]);
   //return status.text;
   return statuses[0];
  } catch (TwitterException e) {
   Log.e(Logtag, e.toString());
   e.printStackTrace();
   return "Failed to post to Twitter";
  }

}

Log file:

E/dalvikvm(  719): Could not find method javax.swing.JOptionPane.showInputDialog, referenced from method winterwell.jtwi
tter.OAuthSignpostClient.askUser
W/dalvikvm(  719): VFY: unable to resolve static method 443: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Objec
t;)Ljava/lang/String;
W/dalvikvm(  719): VFY:  rejecting opcode 0x71 at 0x0000
W/dalvikvm(  719): VFY:  rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/Strin
g;
W/dalvikvm(  719): Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
W/dalvikvm(  719): threadid=17: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime(  719): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime(  719): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(  719):        at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:234)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:258)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask.run(FutureTask.java:122)
E/AndroidRuntime(  719):        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
E/AndroidRuntime(  719):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
E/AndroidRuntime(  719):        at java.lang.Thread.run(Thread.java:1058)
E/AndroidRuntime(  719): Caused by: java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
E/AndroidRuntime(  719):        at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:81)
E/AndroidRuntime(  719):        at com.ravi.tweeto.StatusActivity$PostToTwitter.doInBackground(StatusActivity.java:1)
E/AndroidRuntime(  719):        at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime(  719):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
E/AndroidRuntime(  719):        ... 4 more
I/Process (  585): Sending signal. PID: 719 SIG: 3
I/dalvikvm(  719): threadid=7: reacting to signal 3
I/dalvikvm(  719): Wrote stack trace to '/data/anr/traces.txt'
----


来源: stackexchange

问:
How to chain a method call to a `do ... end` block in Ruby?
I'm doing the following:

```<code>array_variable = collection.map do |param|
  some value with param
end
return array_variable.compact
</code>```

Can I call map and compact in one statement somehow, so I can return the result instantly?

I'm thinking on something like this (it may be invalid, however):

```<code>array_variable = block_code param.compact
# block_code here is a method for example which fills the array
</code>```

答:
yes, you can call a method here.

In your case,

```<code>array_variable = collection.map do |param|
  # some value with param
end.compact
</code>```

OR

```<code>array_variable = collection.map{ |param| some value with param }.compact
</code>```

As pointed out by @Stefan, assignment is not required, you can directly use return and if that's the last line of method you can omit return too..

ContentLicense: CC BY-SA 3.0

Body:
I'm doing the following:

array_variable = collection.map do |param|
  some value with param
end
return array_variable.compact

Can I call map and compact in one statement somehow, so I can return the result instantly?

I'm thinking on something like this (it may be invalid, however):

array_variable = block_code param.compact
# block_code here is a method for example which fills the array

Body:
yes, you can call a method here.

In your case,

array_variable = collection.map do |param|
  # some value with param
end.compact

OR

array_variable = collection.map{ |param| some value with param }.compact

As pointed out by @Stefan, assignment is not required, you can directly use return and if that's the last line of method you can omit return too..


问:
Laravel 5.4 set and increment custom session variable
Im new to Laravel. Im trying to set a counter of failed login attempts by using sessions. However I not able to make it work. Here is my UserController handling registration, login and logout. I wanna have a global variable, which I can access from the login form and force user to use CAPTCHA if there is more than 2 failed logins

```<code>public function postSignIn(Request $request)
{
   $failedAttempt = Session::get('FailedAttempts');
   if(!isset($failedAttempt)) $failedAttempt = 0;

    $this->validate($request, [
        'email' => 'required',
        'password' => 'required'
    ]);
    if (Auth::attempt(['email' => $request['email'], 'password' =>
           $request['password'], 'active' => 1])) {
        return redirect()->route('dashboard');
    } else {
        $failedAttempt++;
        Session::put('FailedAttempts', $failedAttempt);
        dd("Counter: " . $failedAttempt); //<- Always 1!!!
    }
</code>```

$failedAttempt never gets incremented on the next failed login attempts. I've tried Session::set('FailedAttempts', $failedAttempt);, session(['FailedAttempts' => $failedAttempt]); but still no luck

答:
i am sure you are making mistake at some point . try this to make a request to insert / put value to session </p>

```<code>https://laracasts.com/discuss/channels/eloquent/how-to-set-a-session-variable?page=1
</code>```

Body:
Im new to Laravel. Im trying to set a counter of failed login attempts by using sessions. However I not able to make it work. Here is my UserController handling registration, login and logout. I wanna have a global variable, which I can access from the login form and force user to use CAPTCHA if there is more than 2 failed logins

public function postSignIn(Request $request)
{
   $failedAttempt = Session::get('FailedAttempts');
   if(!isset($failedAttempt)) $failedAttempt = 0;

    $this->validate($request, [
        'email' => 'required',
        'password' => 'required'
    ]);
    if (Auth::attempt(['email' => $request['email'], 'password' =>
           $request['password'], 'active' => 1])) {
        return redirect()->route('dashboard');
    } else {
        $failedAttempt++;
        Session::put('FailedAttempts', $failedAttempt);
        dd("Counter: " . $failedAttempt); //<- Always 1!!!
    }

$failedAttempt never gets incremented on the next failed login attempts. I've tried Session::set('FailedAttempts', $failedAttempt);, session(['FailedAttempts' => $failedAttempt]); but still no luck

Body:
i am sure you are making mistake at some point . try this to make a request to insert / put value to session

https://laracasts.com/discuss/channels/eloquent/how-to-set-a-session-variable?page=1


问:
How can I put 2 collectionViews in a single ViewController?
I have this code to make a UICollectionView with in another ViewController:

```<code>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return tvSeries.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let identifier = "Item"
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! SeriesCollectionViewCell
    cell.itemLabel.text = tvSeries[indexPath.row]
    cell.itemImage.image = UIImage.init(imageLiteralResourceName: tvSeries[indexPath.row])

    return cell
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let item = sender as? UICollectionViewCell
    let indexPath = collectionView.indexPath(for: item!)
    let detailVC = segue.destination as! DetailViewController
    detailVC.detailName = tvSeries[(indexPath?.row)!]
}
</code>```

I want to have a ViewController with 2 CollectionViews like in this picture:

答:
In your collectionView functions such as numberOfItemsInSection, check if the collectionView argument is equal to one or the other collection view and then return the number as required.

For example, if you had the following IBOutlets:

```<code>@IBOutlet weak var collectionViewOne: UICollectionView!
@IBOutlet weak var collectionViewTwo: UICollectionView!
</code>```

then your numberOfItemsInSection would change to:

```<code>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    if collectionView == collectionViewOne {
        return itemSource1.count
    }
    else {
        return itemSource2.count
    }
}
</code>```

Do the same for the rest of the collectionView functions.

Body:
I have this code to make a UICollectionView with in another ViewController:

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return tvSeries.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let identifier = "Item"
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! SeriesCollectionViewCell
    cell.itemLabel.text = tvSeries[indexPath.row]
    cell.itemImage.image = UIImage.init(imageLiteralResourceName: tvSeries[indexPath.row])

    return cell
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let item = sender as? UICollectionViewCell
    let indexPath = collectionView.indexPath(for: item!)
    let detailVC = segue.destination as! DetailViewController
    detailVC.detailName = tvSeries[(indexPath?.row)!]
}

I want to have a ViewController with 2 CollectionViews like in this picture:

Body:
In your collectionView functions such as numberOfItemsInSection, check if the collectionView argument is equal to one or the other collection view and then return the number as required.

For example, if you had the following IBOutlets:

@IBOutlet weak var collectionViewOne: UICollectionView!
@IBOutlet weak var collectionViewTwo: UICollectionView!

then your numberOfItemsInSection would change to:

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    if collectionView == collectionViewOne {
        return itemSource1.count
    }
    else {
        return itemSource2.count
    }
}

Do the same for the rest of the collectionView functions.


问:
Load script or CDN after ajax call
I'm trying to run this ajax method for multi select drop down:-

```<code>success: function (data) {
            var drop_down_option = '<select name="langOpt3[]" multiple id="langOpt3">';

            var check = JSON.parse(data)
            console.log(check);
            for (var i in check) {
                console.log(check[i].branchId + ',' + check[i].validbranches);
                drop_down_option += '<option id="' + check[i].branchId +  '">' + check[i].validbranches + '</option>';
            }

            drop_down_option += '</select>';
            document.getElementById("checkID").innerHTML = drop_down_option;

        },
        async: false
</code>```

When i use the static multi select drop down on the html it works without red box, image shown as below :-

And which is not working is shown in red box:-

These scripts i'm using :-

```<code><link href="~/css/jquery.multiselect.css" rel="stylesheet" />
<script src="~/js/jquery.multiselect.js"></script>
<script src="/js/jquery.min.js"> </script>
</code>```

The issue as i see is that in case of dynamic my scripts runs before page load and thus this dynamic ajax don't show drop down,but in case of static multi select drop down it works because this drop down is before the page loads and thus the script runs over it how do i run ajax before page call or before these scripts run.

答:
Just call your .selectMultiple event function in your ajax success method after inserting your select tag in DOM</p>

```<code>success: function (data) {
        var drop_down_option = '<select name="langOpt3[]" multiple id="langOpt3">';

        var check = JSON.parse(data)
        console.log(check);
        for (var i in check) {
            console.log(check[i].branchId + ',' + check[i].validbranches);
            drop_down_option += '<option id="' + check[i].branchId +  '">' + check[i].validbranches + '</option>';
        }

        drop_down_option += '</select>';
        document.getElementById("checkID").innerHTML = drop_down_option;

       $('#langOpt3').selectMultiple(
        //your code
       );

    }
</code>```

Title: Load script or CDN after ajax call

Body:
I'm trying to run this ajax method for multi select drop down:-

success: function (data) {
            var drop_down_option = '<select name="langOpt3[]" multiple id="langOpt3">';

            var check = JSON.parse(data)
            console.log(check);
            for (var i in check) {
                console.log(check[i].branchId + ',' + check[i].validbranches);
                drop_down_option += '<option id="' + check[i].branchId +  '">' + check[i].validbranches + '</option>';
            }

            drop_down_option += '</select>';
            document.getElementById("checkID").innerHTML = drop_down_option;

        },
        async: false

When i use the static multi select drop down on the html it works without red box, image shown as below :-

And which is not working is shown in red box:-

These scripts i'm using :-

<link href="~/css/jquery.multiselect.css" rel="stylesheet" />

The issue as i see is that in case of dynamic my scripts runs before page load and thus this dynamic ajax don't show drop down,but in case of static multi select drop down it works because this drop down is before the page loads and thus the script runs over it how do i run ajax before page call or before these scripts run.

Body:
Just call your .selectMultiple event function in your ajax success method after inserting your select tag in DOM

success: function (data) {
        var drop_down_option = '<select name="langOpt3[]" multiple id="langOpt3">';

        var check = JSON.parse(data)
        console.log(check);
        for (var i in check) {
            console.log(check[i].branchId + ',' + check[i].validbranches);
            drop_down_option += '<option id="' + check[i].branchId +  '">' + check[i].validbranches + '</option>';
        }

        drop_down_option += '</select>';
        document.getElementById("checkID").innerHTML = drop_down_option;

       $('#langOpt3').selectMultiple(
        //your code
       );

    }


问:
How do I execute a sed command from a Bash variable?
I have a sed command that works when executed directly.

```<code>echo foo > /home/user/bar
sed -i 's/foo/zoo/' /home/user/bar
</code>```

It also works when directly embedded in $(...) or `...`.

However, if I try to execute it from a Bash variable, I get an error:

```<code>CMD="sed -i 's/foo/zoo/' /home/user/bar"
$CMD
</code>```

Error:

sed: -e expression #1, char 1: unknown command: `''

It also works if I echo it out and source the file:

```<code>echo $CMD > file
source file
</code>```

What's going on here, and how do I get the sed command to run from a Bash variable?

答:
Don't store full command a string variable to avoid word splitting. Use an array or shell function:

```<code># store command in an array
cmd=(sed -i 's/foo/zoo/' /home/user/bar)

# execute the command
"${cmd[@]}"
</code>```

Or else use a shell function:

```<code>fn() {
   sed -i 's/foo/zoo/' /home/user/bar
}

#call it as:
fn
</code>```

Read this BASH FAQ: I'm trying to put a command in a variable, but the complex cases always fail!

Body:
I have a sed command that works when executed directly.

echo foo > /home/user/bar
sed -i 's/foo/zoo/' /home/user/bar

It also works when directly embedded in $(...) or `...`.

However, if I try to execute it from a Bash variable, I get an error:

CMD="sed -i 's/foo/zoo/' /home/user/bar"
$CMD

Error:

sed: -e expression #1, char 1: unknown command: `''

It also works if I echo it out and source the file:

echo $CMD > file
source file

What's going on here, and how do I get the sed command to run from a Bash variable?

Body:
Don't store full command a string variable to avoid word splitting. Use an array or shell function:

# store command in an array
cmd=(sed -i 's/foo/zoo/' /home/user/bar)

# execute the command
"${cmd[@]}"

Or else use a shell function:

fn() {
   sed -i 's/foo/zoo/' /home/user/bar
}

#call it as:
fn

Read this BASH FAQ: I'm trying to put a command in a variable, but the complex cases always fail!


问:
how can I store different value in different ArrayList in android
I'm working with string value like this String result "aa,bb,cc,dd,ee".

And already split it into aa bb cc dd ee with

```<code>qrList = result.getContents().toString().split("\\,");
List<String> resultToString= new ArrayList(Arrays.asList(qrList));
</code>```

Then I create four ArrayLists.

```<code> ArrayList<String> strA = new ArrayList();
 ArrayList<String> strB = new ArrayList();
 ArrayList<String> strCD = new ArrayList();
 ArrayList<String> strE = new ArrayList();
</code>```

When I use this code below to store string into each new ArrayList.

```<code>for(int count=0; count<resultToString.size(); count++){
    //separate string to array list
    if(count%5==0){
        strA.add(resultToString.get(count));
    }else if(count%5==1){
        strB.add(resultToString.get(count));
    }else if(count%5==2||count%5==3){
        strCD.add(resultToString.get(count));
    }else if(count==4){
        strE.add(resultToString.get(count));
    }
</code>```

The correct result would be

strA stored aa

strB stored bb

strCD stored cc and dd

strE stored ee

It doesn't work because I only get the index value at 0 (strA stored aa).
What should I do to improve my code?

答:
Modulus operator describes the remainder of your equation.  Let us show and explain an example:

As explained in this documentation, performing modulus between two values will only show you the remainder value.  For e.g. 8 % 3 == 2 because 8 divided by 3 leaves a remainder of 2.

The reason your code is not showing your desired results is due to the usage of your modulus operator.  Regarding improving your code, I can tell that all you wanted is to use the Array List index so as to add the string from the resultToString
Array List.

Therefore I would modify your loop in the following manner:

```<code>for(int count=0; count < resultToString.size(); count++) {
  //separate string to array list
  if (count == 0){
     strA.add(resultToString.get(count));
  } else if (count == 1){
     strB.add(resultToString.get(count));
  } else if (count == 2 || count == 3){
     strCD.add(resultToString.get(count));
  } else if (count == 4){
     strE.add(resultToString.get(count));
  }
}
</code>```

An alternative is to loop directly on the resulting String[] and use that relative counter in the for loop for e.g.

```<code>String[] qrList = results.getContent().toString().split("\\,");

for(int count = 0; count < qrList.length; count++) {
  //each index represents the split string e.g
  // [0] == "aa"
  // [1] == "bb"
  // [2] == "cc"
  // [3] == "dd"
  // [4] == "ee"
  if (count == 0){
     strA.add(qrList[count]);
  } else if (count == 1){
     strB.add(qrList[count]);
  } else if (count == 2 || count == 3){
     strCD.add(qrList[count]);
  } else if (count == 4){
     strE.add(qrList[count]);
  }
}
</code>```

Body:
I'm working with string value like this String result "aa,bb,cc,dd,ee".

And already split it into aa bb cc dd ee with

qrList = result.getContents().toString().split("\\,");
List<String> resultToString= new ArrayList(Arrays.asList(qrList));

Then I create four ArrayLists.

 ArrayList<String> strA = new ArrayList();
 ArrayList<String> strB = new ArrayList();
 ArrayList<String> strCD = new ArrayList();
 ArrayList<String> strE = new ArrayList();

When I use this code below to store string into each new ArrayList.

for(int count=0; count<resultToString.size(); count++){
    //separate string to array list
    if(count%5==0){
        strA.add(resultToString.get(count));
    }else if(count%5==1){
        strB.add(resultToString.get(count));
    }else if(count%5==2||count%5==3){
        strCD.add(resultToString.get(count));
    }else if(count==4){
        strE.add(resultToString.get(count));
    }

The correct result would be

strA stored aa

strB stored bb

strCD stored cc and dd

strE stored ee

It doesn't work because I only get the index value at 0 (strA stored aa).
What should I do to improve my code?

Body:
Modulus operator describes the remainder of your equation.  Let us show and explain an example:

As explained in this documentation, performing modulus between two values will only show you the remainder value.  For e.g. 8 % 3 == 2 because 8 divided by 3 leaves a remainder of 2.

The reason your code is not showing your desired results is due to the usage of your modulus operator.  Regarding improving your code, I can tell that all you wanted is to use the Array List index so as to add the string from the resultToString
Array List.

Therefore I would modify your loop in the following manner:

for(int count=0; count < resultToString.size(); count++) {
  //separate string to array list
  if (count == 0){
     strA.add(resultToString.get(count));
  } else if (count == 1){
     strB.add(resultToString.get(count));
  } else if (count == 2 || count == 3){
     strCD.add(resultToString.get(count));
  } else if (count == 4){
     strE.add(resultToString.get(count));
  }
}

An alternative is to loop directly on the resulting String[] and use that relative counter in the for loop for e.g.

String[] qrList = results.getContent().toString().split("\\,");

for(int count = 0; count < qrList.length; count++) {
  //each index represents the split string e.g
  // [0] == "aa"
  // [1] == "bb"
  // [2] == "cc"
  // [3] == "dd"
  // [4] == "ee"
  if (count == 0){
     strA.add(qrList[count]);
  } else if (count == 1){
     strB.add(qrList[count]);
  } else if (count == 2 || count == 3){
     strCD.add(qrList[count]);
  } else if (count == 4){
     strE.add(qrList[count]);
  }
}


问:
How can I set up rule for selectable FullCalendar
I am trying to set up a rule for selectable attribute. The rule should be like this:
 selectable attribute is true for future weeks, otherwise false
However, I could not find how can I check dates in calendar option. I tried some ways but javascript does not accept these ways. Here is my current option. Any helps ?

```<code>$(document).ready(function () {

        $('#calendar').fullCalendar({
        //some options
        //some options

            selectable: true,
            selectHelper: true,

            select: function (start, end) {
                var title = loadRequired("ff8081815c776701015c7788151d06b4",
                    "activity",
                    "@Session["token"].ToString()");
                var eventData;
                if (title) {
                    eventData = {
                        title: title,
                        start: start,
                        end: end
                    };
                    $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
                }
                $('#calendar').fullCalendar('unselect');
            },
     });
</code>```

});

答:
I checked situation on select atrr.

```<code>select: function (start, end) {
    var check = end.unix()*1000;
    var today = @weekdays[6]*1;

    if(today > check)
    {
        $('#calendar').fullCalendar('unselect');

    }else
    {
        $('#calendar').fullCalendar('select');
        var title = loadRequired("ff8081815c776701015c7788151d06b4",
            "activity",
            "@Session["token"].ToString()");
        var eventData;
        if (title) {
            eventData = {
                title: title,
                start: start,
                end: end
            };
            $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
        }

    }

},
</code>```

now I can do what I want on functionality. However, I can still select the area on calendar, the area's color changed to blue, then it goes my check point, and if situation is false: unselect atrr is activated.
Is there any way to do this ? Actually selectable attribute should not be true when the area is in the past and should be true on future weeks

Body:
I am trying to set up a rule for selectable attribute. The rule should be like this:
 selectable attribute is true for future weeks, otherwise false
However, I could not find how can I check dates in calendar option. I tried some ways but javascript does not accept these ways. Here is my current option. Any helps ?

$(document).ready(function () {

        $('#calendar').fullCalendar({
        //some options
        //some options

            selectable: true,
            selectHelper: true,

            select: function (start, end) {
                var title = loadRequired("ff8081815c776701015c7788151d06b4",
                    "activity",
                    "@Session["token"].ToString()");
                var eventData;
                if (title) {
                    eventData = {
                        title: title,
                        start: start,
                        end: end
                    };
                    $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
                }
                $('#calendar').fullCalendar('unselect');
            },
     });

});

Body:
I checked situation on select atrr.

select: function (start, end) {
    var check = end.unix()*1000;
    var today = @weekdays[6]*1;

    if(today > check)
    {
        $('#calendar').fullCalendar('unselect');

    }else
    {
        $('#calendar').fullCalendar('select');
        var title = loadRequired("ff8081815c776701015c7788151d06b4",
            "activity",
            "@Session["token"].ToString()");
        var eventData;
        if (title) {
            eventData = {
                title: title,
                start: start,
                end: end
            };
            $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
        }

    }

},

now I can do what I want on functionality. However, I can still select the area on calendar, the area's color changed to blue, then it goes my check point, and if situation is false: unselect atrr is activated.
Is there any way to do this ? Actually selectable attribute should not be true when the area is in the past and should be true on future weeks


问:
java unknown protocol: e when downloading a file
I'm a beginner to java file handling. I tired to get a bin file (en-parser-chunking.bin) from my hard disk partition to my web application. So far I have tried below code and it gives me the output in my console below.

unknown protocol: e

these are the code samples I have tried so far

```<code>//download file
public void download(String url, File destination) throws IOException {
    URL website = new URL(url);
    ReadableByteChannel rbc = Channels.newChannel(website.openStream());
    FileOutputStream fos = new FileOutputStream(destination);
    fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}

public void parserAction() throws Exception {
    //InputStream is = new FileInputStream("en-parser-chunking.bin");
    File modelFile = new File("en-parser-chunking.bin");

    if (!modelFile.exists()) {
        System.out.println("Downloading model.");
        download("E:\\Final Project\\Softwares and tools\\en-parser-chunking.bin", modelFile);
    }

    ParserModel model = new ParserModel(modelFile);
    Parser parser = ParserFactory.create(model);
    Parse topParses[] = ParserTool.parseLine(line, parser, 1);
    for (Parse p : topParses){
        //p.show();
        getNounPhrases(p);
    }
}
</code>```

getting a file in this way is possible or I have done it wrong ?

note - I need to get this from my hard disk. not download from the internet

答:
the correct URL for a local file is:

```<code>file://E:/Final Project/Softwares and tools/en-parser-chunking.bin
</code>```

where file is the protocol.

You can also you:

```<code>new File("E:/Final Project/Softwares and tools/en-parser-chunking.bin").toURL()
</code>```

to create a URL from your file.

I also recomment to use slash as file seperator instead of backslash

Body:
I'm a beginner to java file handling. I tired to get a bin file (en-parser-chunking.bin) from my hard disk partition to my web application. So far I have tried below code and it gives me the output in my console below.

unknown protocol: e

these are the code samples I have tried so far

//download file
public void download(String url, File destination) throws IOException {
    URL website = new URL(url);
    ReadableByteChannel rbc = Channels.newChannel(website.openStream());
    FileOutputStream fos = new FileOutputStream(destination);
    fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}

public void parserAction() throws Exception {
    //InputStream is = new FileInputStream("en-parser-chunking.bin");
    File modelFile = new File("en-parser-chunking.bin");

    if (!modelFile.exists()) {
        System.out.println("Downloading model.");
        download("E:\\Final Project\\Softwares and tools\\en-parser-chunking.bin", modelFile);
    }

    ParserModel model = new ParserModel(modelFile);
    Parser parser = ParserFactory.create(model);
    Parse topParses[] = ParserTool.parseLine(line, parser, 1);
    for (Parse p : topParses){
        //p.show();
        getNounPhrases(p);
    }
}

getting a file in this way is possible or I have done it wrong ?

note - I need to get this from my hard disk. not download from the internet

Body:
the correct URL for a local file is:

file://E:/Final Project/Softwares and tools/en-parser-chunking.bin

where file is the protocol.

You can also you:

new File("E:/Final Project/Softwares and tools/en-parser-chunking.bin").toURL()

to create a URL from your file.

I also recomment to use slash as file seperator instead of backslash


问:
Install rJava on RHEL6: even with identical Java path I get: error: One or more JNI types differ from the corresponding native type
I am working on a Linux server RHEL6 and I installed anaconda. I have the following setup

```<code> conda-env version : 4.3.13
 conda-build version : 2.1.4
 python version : 2.7.13.final.0
 rpy2 : 2.8.5
</code>```

I installed rpy2 to use R in python. But with the version of R installed with conda I have issue to installed "rJava".

```<code>checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package 'rJava'
</code>```

With my standalone version of R installed on the same machine I don't have issue, so I know I have the correct version installed.

For my 2 different setup with the same R version (standalone R with R with conda), I have the same Java version

```<code> java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
</code>```

For both setup, the following variables doesn't exit

```<code>R_JAVA_LD_LIBRARY_PATH
JAVA_HOME
</code>```

defined. The PATH are very similar for standalone:

```<code>PATH=/opt/ccda/anaconda2/bin:/opt/opennlp/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
</code>```

while for R installed with conda I have:

```<code>PATH=/opt/ccda/anaconda2/envs/py27CCA/bin:/opt/ccda/anaconda2/bin:/opt/ccda/anaconda2/bin:/opt/opennlp/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
</code>```

Here the info during the compilation. For the standalone R version:

```<code>interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm
</code>```

While for the R version installed with conda:

```<code>interpreter : '/usr/lib/jvm/java/jre/bin/java'
archiver    : '/usr/lib/jvm/java/jre/../bin/jar'
compiler    : '/usr/lib/jvm/java/jre/../bin/javac'
header prep.: '/usr/lib/jvm/java/jre/../bin/javah'
cpp flags   : '-I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm'
</code>```

I tried to get the same path using:

```<code>export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
export R_JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/lib/amd64/server
export JAVA_CPPFLAGS="-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux"
</code>```

by the way:

```<code>/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
</code>```

but after rerunning:

```<code> R CMD javareconf
</code>```

and recompiling I get the same error while the path seems the same now:

```<code>interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm'
</code>```

so I don't understand what this means "One or more JNI types differ" and what I should in path and flag to have it working.

```<code>R CMD javareconf
Java interpreter : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
Java version     : 1.8.0_121
Java home path   : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64
Java compiler    : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/javac
Java headers gen.: /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/javah
Java archive tool: /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux
detected JNI linker flags : -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/opt/ccda/anaconda2/envs/py27CCA/lib/R/include -DNDEBUG -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux -I/opt/ccda/anaconda2/envs/py27CCA/include    -fpic  -I/opt/ccda/anaconda2/envs/py27CCA/include  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/opt/ccda/anaconda2/envs/py27CCA/lib/R/lib -L/opt/ccda/anaconda2/envs/py27CCA/lib -lgfortran -o conftest.so conftest.o -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm -L/opt/ccda/anaconda2/envs/py27CCA/lib/R/lib -lR

JAVA_HOME        : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64
Java library path: /usr/lib/jvm/java/jre/lib/amd64/server
JNI cpp flags    : -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux
JNI linker flags : -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm
Updating Java configuration in /opt/ccda/anaconda2/envs/py27CCA/lib/R
Done.
</code>```

I am out of idea since I don't really understand the meaning of the error messages. I tried all the suggestion from the various thread related to similar issues.

Edit: using export

```<code>LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64:$JAVA_HOME/lib/amd64/server
</code>```

solve part of the problem (in such case JAVA_HOME is not needed anymore) but i there is too other issue:

-m64 flags is not used in this case (while it is used with the standalone R version)

/usr/bin/ld: cannot find -liconv

but the library exist:

```<code>/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so
/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so.2
/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so.2.5.1
/opt/ccda/anaconda2/envs/py27CCA/lib/preloadable_libiconv.so
</code>```

but may be not in the path used so I need to fix this now.

答:
Make sure to reconfigure your R environment with explicit settings pointing to JDK.

Make sure that JAVA_HOME points to JDK

```<code>export JAVA_HOME=your_JDK_installation
</code>```

Then, reconfigure R and pass all the locations explicitly

```<code>sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar \
JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/server \
JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"
</code>```

Then, try to configure rJava outside R

```<code>curl https://cran.r-project.org/src/contrib/rJava_0.9-8.tar.gz -o rJava_0.9-8.tar.gz
tar zxf rJava_0.9-8.tar.gz
cd rJava
./configure
</code>```

if it works, you should be able to install it from sources inside R

install.packages("rJava", type="source")

Body:
I am working on a Linux server RHEL6 and I installed anaconda. I have the following setup

 conda-env version : 4.3.13
 conda-build version : 2.1.4
 python version : 2.7.13.final.0
 rpy2 : 2.8.5

I installed rpy2 to use R in python. But with the version of R installed with conda I have issue to installed "rJava".

checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package 'rJava'

With my standalone version of R installed on the same machine I don't have issue, so I know I have the correct version installed.

For my 2 different setup with the same R version (standalone R with R with conda), I have the same Java version

 java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

For both setup, the following variables doesn't exit

R_JAVA_LD_LIBRARY_PATH
JAVA_HOME

defined. The PATH are very similar for standalone:

PATH=/opt/ccda/anaconda2/bin:/opt/opennlp/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

while for R installed with conda I have:

PATH=/opt/ccda/anaconda2/envs/py27CCA/bin:/opt/ccda/anaconda2/bin:/opt/ccda/anaconda2/bin:/opt/opennlp/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Here the info during the compilation. For the standalone R version:

interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm

While for the R version installed with conda:

interpreter : '/usr/lib/jvm/java/jre/bin/java'
archiver    : '/usr/lib/jvm/java/jre/../bin/jar'
compiler    : '/usr/lib/jvm/java/jre/../bin/javac'
header prep.: '/usr/lib/jvm/java/jre/../bin/javah'
cpp flags   : '-I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm'

I tried to get the same path using:

export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
export R_JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/lib/amd64/server
export JAVA_CPPFLAGS="-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux"

by the way:

/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

but after rerunning:

 R CMD javareconf

and recompiling I get the same error while the path seems the same now:

interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm'

so I don't understand what this means "One or more JNI types differ" and what I should in path and flag to have it working.

R CMD javareconf
Java interpreter : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
Java version     : 1.8.0_121
Java home path   : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64
Java compiler    : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/javac
Java headers gen.: /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/javah
Java archive tool: /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/../bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux
detected JNI linker flags : -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/opt/ccda/anaconda2/envs/py27CCA/lib/R/include -DNDEBUG -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux -I/opt/ccda/anaconda2/envs/py27CCA/include    -fpic  -I/opt/ccda/anaconda2/envs/py27CCA/include  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/opt/ccda/anaconda2/envs/py27CCA/lib/R/lib -L/opt/ccda/anaconda2/envs/py27CCA/lib -lgfortran -o conftest.so conftest.o -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm -L/opt/ccda/anaconda2/envs/py27CCA/lib/R/lib -lR

JAVA_HOME        : /usr/lib/jvm/jre-1.8.0-openjdk.x86_64
Java library path: /usr/lib/jvm/java/jre/lib/amd64/server
JNI cpp flags    : -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include -I/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/../include/linux
JNI linker flags : -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el6_8.x86_64/jre/lib/amd64/server -ljvm
Updating Java configuration in /opt/ccda/anaconda2/envs/py27CCA/lib/R
Done.

I am out of idea since I don't really understand the meaning of the error messages. I tried all the suggestion from the various thread related to similar issues.

Edit: using export

LD_LIBRARY_PATH=$JAVA_HOME/lib/amd64:$JAVA_HOME/lib/amd64/server

solve part of the problem (in such case JAVA_HOME is not needed anymore) but i there is too other issue:

-m64 flags is not used in this case (while it is used with the standalone R version)

/usr/bin/ld: cannot find -liconv

but the library exist:

/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so
/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so.2
/opt/ccda/anaconda2/envs/py27CCA/lib/libiconv.so.2.5.1
/opt/ccda/anaconda2/envs/py27CCA/lib/preloadable_libiconv.so

but may be not in the path used so I need to fix this now.

Body:
Make sure to reconfigure your R environment with explicit settings pointing to JDK.

Make sure that JAVA_HOME points to JDK

export JAVA_HOME=your_JDK_installation

Then, reconfigure R and pass all the locations explicitly

sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar \
JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/server \
JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"

Then, try to configure rJava outside R

curl https://cran.r-project.org/src/contrib/rJava_0.9-8.tar.gz -o rJava_0.9-8.tar.gz
tar zxf rJava_0.9-8.tar.gz
cd rJava
./configure

if it works, you should be able to install it from sources inside R

install.packages("rJava", type="source")