Go Premium for a chance to win a PS4. Enter to Win

x

Java

98K

Solutions

32K

Contributors

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

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

Sign up to Post

I'm following this LDAP authentication code

LDAP Authentication code

replaced parameters with my own parameters to authenticate  with OpenLDAP 2.4.31


public static void main(String[] args)
	{
		String username = "jsmith";
		String password = "password@123"; 
		String base = "ou=people,dc=nodomain";
		String dn = "uid=" + username + "," + base;
		String ldapURL = "ldap://xx.xx.xx.xx:389";

		// Setup environment for authenticating
		
		Hashtable<String, String> environment = 
			new Hashtable<String, String>();
		environment.put(Context.INITIAL_CONTEXT_FACTORY,
				"com.sun.jndi.ldap.LdapCtxFactory");
		environment.put(Context.PROVIDER_URL, ldapURL);
		environment.put(Context.SECURITY_AUTHENTICATION, "simple");
		environment.put(Context.SECURITY_PRINCIPAL, dn);
		environment.put(Context.SECURITY_CREDENTIALS, password);

		try
		{
			DirContext authContext = 
				new InitialDirContext(environment);
			System.out.println("authentication success!");
			
			// user is authenticated
			
		}
		catch (AuthenticationException ex)
		{
			System.out.println("authentication failed!");   // I'm getting this print
			// Authentication failed

		}
		catch (NamingException ex)
		{
			ex.printStackTrace();
		}
	}
}

Open in new window


I am getting authentication failure message . ..what I'm doing wrong ?  ..unable to find the root cause.
Do I need to send password encrypted  ?
0
How to Use the Help Bell
LVL 11
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Which technologies are  required  for SAML implementation.
And Saml  is to be  implemented  with  those technologies.
I  need  detail  information  on this as I am assigned that  task.
On net I   am  able to  find lot of articles  explaining how saml
works but I  did not find anything  practically  how it is implemented.
Instead  of  Service provider  we are  going to use  our own server.
0
hi,

I am not able to see xsl:when option while writing a xsl in the eclipse ide

not sure why? i am seeing other options though.
 how to get it xsl:when option as well ?

<td>
                                    <xslxsl:choose>
                                    <xsl:when
xslWhenMissing.png
0
I am working with a very large, very complicated schema.  I currently use this schema in JAVA to create XML files based on Job Information.  I am now being asked to also capture the data from each XML file and save to a CSV file, appending records for each job processed. Data from each job varies, so I need to make sure that the CSV file contains all nodes from the schema. I need advice on how to accomplish this.  

Thanks,
0
My users are having issues opening PDF from IE 11.  The add on is enabled and so is Java.  I've tried reinstalling and it works for a while but the problem comes back again. Any suggestions?
0
Hello guys,

I want to invest some time to study a new language for developing application for mobile (cell phone).

Nowaday I work with Delphi and I know that some last version of it, it is possible to build application for mobile,

but I am not sure if it worths it.

What should be the better language to start it? Java, Delphi, Visual Studio?

I'd like an opinion from you.

Thanks a lot
Alexandre
0
$certStore=dirname(__FILE__)."/cert/cert.pem";
            $caStore=dirname(__FILE__)."/cert/ca.pem";
            $keyStore=dirname(__FILE__)."/cert/key.pem";
            
        $keyPass=$this->session->data['key'];
            $keyStoreType= "PEM";
            $ch= curl_init();
            curl_setopt($ch, CURLOPT_URL, $gateway_url);
            curl_setopt($ch, CURLOPT_VERBOSE, true);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
            curl_setopt($ch, CURLOPT_PORT, 443);
            curl_setopt($ch, CURLOPT_CAINFO,$caStore);
            curl_setopt($ch, CURLOPT_SSLCERT,$certStore);
            curl_setopt($ch, CURLOPT_SSLKEY,$keyStore);
            curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $keyPass);
            curl_setopt($ch, CURLOPT_SSLKEYTYPE,$keyStoreType);        
            $headers = array();
       array_push($headers, "Content-Type: text/xml; charset=utf-8");
       array_push($headers, "SOAPAction: sii:RB_OLP_INITIATE_PAYMENT");
       array_push($headers, "Host:b2brbtest.riyadbank.com");
            if($request_string != null) {
       curl_setopt($ch, CURLOPT_POSTFIELDS, $request_string);
       array_push($headers, "Content-Length: " . strlen($request_string));
     }
            curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
            
       curl_setopt($ch, CURLOPT_POST, true);
0
Hello

I'm new to coding (total novice) and i am having trouble with the following program. (see below and question attached)

How do I print out my assignGrade method??? I had to initialise it in Main manually. The rest of the program works fine?
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package Lab8;
import java.util.Scanner;

public class ClassTest2Retry {

    static Scanner input = new Scanner(System.in);

    //method enterName()
    public static String enterName(){
        System.out.println("Enter name");
        return input.nextLine();
    }
    //method enterMark()
    public static int enterMark(String value){
        System.out.println(value);
        return input.nextInt();
    }
    //method calculateAverage()
    public static int calculateaverage(int solo, int prose, int poem){
        return ((solo + prose + poem) /3);
    }
    // method assignGrade
    public static String assignGrade(int overall){
        if (overall <40){
            return "Fail";
        }else if (overall >40) {
            return "Pass";
        }
            else{
                return "Distinction";
            }
    }
    //method output results
    public static void outputResults (String name, int solo, int prose, int poem, int average, String grade){
        System.out.println("Name\t\t\t\t Solo\t\t\t\t …
0
My work place uses Kronos to keep up with employee hours and it works with Java.

The problem is to administrate Kronos requires version 6.29. If you do not have version 6.29 the screen will never show the users. Kronos works fine with the new version of java as long as you do not administer anything.

Another website work uses is called state sessions, and state session requires a new version of Java.

I have 6.29 & the new Java installed, but when I try to use the admin function Kronos I get “application blocked by java security.” Reason: your security settings have block an application with an out of date version of Java. I've tried somewhat older versions of Java such as like Java 8_131, still the same.

I assume this is the new java client causing this message. I go into the Java setup, and put the Kronos web address(s) in the exception site list but no luck. In the java security tab all I see is high & very high settings, no lower settings to try.

I have attached the screen shot of the error message I see when trying to admin Kronos.

I highly, highly, doubt the admin part of Kronos will be updated.

Some particular employees that do the Kronos admin severely need both the website & Kronos at the same time.

I'm not sure where to go from here.

Any ideas?

Thanks
0
Hi,

I imported one project as existing maven project. I am seeing below error while adding tomcat 8 as runtime

An internal error occurred during: "Updating workspace".
assertion failed: Mismatched begin/endOperation


While resolving below errror by going to properties
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

please advise
0
Hire Technology Freelancers with Gigs
LVL 11
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

I had this question after viewing JSON Terminology - Block or Object/Closer to Java or JavaScript.

Hello again,

I found some JSON similar to the below when running a query:

[
  { 
     time: "15:00",
     temperature: 66
  },
  {
     time: "17:00",
     temperature: 62
]

Open in new window


Is it legal to have an array as the outer entity here? Or, do they need an outer ( } to make it an object? I looked at:
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

but can't tell for sure.

Thanks!
0
hi how to see post man response. i installed post man now instead of advance res client
postMan401.png
postMan200.png
0
Hi,
I'm writing an API guide for an application that accepts input - and generates output - in JSON format.

Suppose I have the following (redacted) code:
{
   SSN :  "012-34-5678",
   DOB: "1986-10-27",
   Age: 30,
   name: {
      first: "Daffy",
      last : "Duck"
    },
   Department: "Sales"
}

Open in new window


1. Is this entire entity referred to as a block or object?
2. Same for the name element, which contains first/last name.

Also, is JSON syntax considered closer to Java? Or to JavaScript?  The reason I need to know the latter is that I'm showing code samples in Confluence. While Confluence has a Code Block Macro, it does not come with prepackaged JSON formatting.

Thanks,
Steve
0
while opening team explored in eclipse mars getting below error

Plug-in "com.microsoft.tfs.client.common.ui" was unable to instantiate class "com.microsoft.tfs.client.common.ui.views.TeamExplorerView".


how to resolve this.

Please advise
0
Experts, please let me know if there is any free client utility that I can use for GitHub Enterprise. I think SourceTree supports GitHub.com, but not GitHub enterprise, please correct me if I am wrong. For some reasons, GitHub Desktop version can't be used. Please let me know if there are any other utilities that I can use to connect to my office GitHub repository.
0
while trying below example

i did all stepas given
http://www.javanbeyond.com/activemq/tomcat-spring-activemq/

when i execute i do not see 3 mesages there

Example Execution:

Start ActiveMQ and login as admin/admin and click on “Queues” tab.
Start Tomcat and deploy the application. You should see three listeners listening to “firstQueue”.

what is difference between
 tcp://127.x.y.z:8161
 tcp://localhost:8161
 http://localhost:8161

which one i have to use.

my active mq running on my own windows laptop locally?
when to use http wen to use ftp?
when to use local host when to use ip like number 127.x.y.z...
please advise
0
Lets say, I have below classes.

@JsonRootName(value = "car")
public class car {
private String make;
private String model;
//getters and setters
}

public class Automobile {
    private String color;
    private String type;
    private Set<Car> cars = new HashSet<>();
//getters and setters
}

When I serialize Automobile using below code
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
mapper.writeValueAsString(Automobile);

I am getting the output
{
  “Automobile”:
   {
    “color”: “red”,
    “type”: “four wheel”,
    “cars”:[{“make”:”Honda”,”model”:”cry”}]
   }
}

But I want something like below
{
  “color”: “red”,
  “type”: “four wheel”,
   “cars”: {
      “car”: [{“make”:”Honda”,”model”:”cry”}]
    }
}

How can i use jackson annotations so that i can get the output i want
0
I got an email "IBM System Director (ISD) storage controller affected by the vulnerability in IBM java run time"

We have windows 2008R2 servers but I am not able to understand where this ISD is installed and how to remediate it. Is it applicable for our environment or not . Please suggest
0
Hi

At the bottom of my humanity changing blog, it says ' © 2017 YOUR COMPANY.  DESIGNED BY THEMEUM'

Can I annihilate this and put my privacy policy link there? or just above it?

not sure

Thanks
0
Concerto's Cloud Advisory Services
LVL 5
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Hi,
i am working on below example
https://howtodoinjava.com/jms/jms-publish-subscribe-message-example/

i wrote my publisher as below

package pubSub;    
 
import javax.naming.Context;
import javax.naming.InitialContext;                                                                          
import javax.jms.Topic;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicPublisher;

import java.util.Properties;

import javax.jms.DeliveryMode;
import javax.jms.TopicSession;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
                                                                            
public class Publisher
{
    public static void main(String[] args) throws Exception
    {
    	// Obtain a JNDI connection
    	Properties env = new Properties();
    	env.put(Context.INITIAL_CONTEXT_FACTORY,“org.apache.activemq.jndi.ActiveMQInitialContextFactory”);
    	env.put(Context.PROVIDER_URL, “http://localhost:8161”);
    	//env.put(Context.SECURITY_PRINCIPAL, “weblogic”);
    	//env.put(Context.SECURITY_CREDENTIALS, “weblogic”);

    	InitialContext ctx = new InitialContext(env);
       // get the initial context
       InitialContext ctx = new InitialContext();
                                                                           
       // lookup the topic object
       Topic topic = (Topic) ctx.lookup("topic/topic0");
                                                                           
       // 

Open in new window

0
hi,
i have a pdf book with some code in it.
how to copy that so that i can execute that code in eclipse or IDE
please advise
0
 public static void main(String[] args) {
        String word;
        char y,a;
        int index;
         int[] num;
        Scanner input = new Scanner(System.in);
        do{
            
        
        System.out.println("Program to convert words to theirs corresponding telephone digits");
        System.out.println("Please enter an 10 character word :");
        word =input.nextLine();
          char phone[]=word.toCharArray();
          for(index = 0;index <word.length();index++){
             
              num =new int[index];
              switch (phone[index]){
                  case 'A':case'B':case'C':case'a':case'b':case'c':
                      
                      num[index]=0;
                      break;
                     case 'D':case'E':case'F':case'd':case'e':case'f': 
                         num[index]=1;
                      break;
                      case 'G':case'H':case'I':case'g':case'h':case'i':
                             num[index]=2;
                      break;
                       case 'J':case'K':case'L':case'j':case'k':case'l':
                             num[index]=3;
                      break;
                      case 'M':case'N':case'O':case'm':case'n':case'o':
                             num[index]=4;
                      break;
                       case 'P':case'Q':case'R':case'p':case'q':case'r':
                             num[index]=5;
                      break;
                       case 

Open in new window

0
hi,

If i do Control+Alt+H on eclipse java class method say methodA() it does show call hierarchy  of who is(lets say methodB()) calling that method (methodA())

If i do control Alt H on methodB() it shows methodC() which is calling methodC()

my question is how to find by selecting methodC() that methodB() is its parent method and methodA() its grand parent method.

i mean to debug upward as well not just downward using call hierarchy.
is there is a way i can do both ways?

please advise
0
I have two HashMaps created from two different hierarchal file structures, one representing Excel files and the other schema definitions. For example,
Map<String, String> xlsMap = new HashMap<String, String>();
Map<String, String> xsdMap = new HashMap<String, String>();
I have a class that populates each with keys that are an identifying name that is common to both. In both cases, the values are the full path and filename where the spreadsheets and schemas reside. Assuming sample values like the following:

xlsMap.put("Parent1","C:\user\documents\Spreadsheets\Parents\Parent1.xls");
xlsMap.put("Child1","C:\user\documents\Spreadsheets\Parents\Dependents\Children\Child1.xls");
xlsMap.put("Child2","C:\user\documents\Spreadsheets\Parents\Dependents\Children\Child2.xls");
xlsMap.put("Dog1","C:\user\documents\Spreadsheets\Dependents\Other\Dog1.xls");
xlsMap.put("Cat1","C:\user\documents\Spreadsheets\Dependents\Other\Cat1.xls");

xsdMap.put("Parent1","C:\user\documents\Schemas\2017v1.0\Parents\table1.xsd");
xsdMap.put("Child1","C:\user\documents\Schemas\2017v1.0\Parents\Dependencies\Child1.xsd");
xsdMap.put("Child2","C:\user\documents\Schemas\2017v1.0\Parents\Dependencies\Child2.xsd");
xsdMap.put("Dog1","C:\user\documents\Schemas\2017v1.0\Dependencies\Other\Dog1.xsd");
xsdMap.put("Cat1","C:\user\documents\Schemas\2017v1.0\Dependencies\Other\Cat1.xsd");
xsdMap.put("Cat2","C:\user\documents\Schemas\2017v1.0\Dependencies\Other\Cat2.xsd");


This indicates a new table …
0
Hello,

As the title states, I am making a simple game program for a introductory Computer science course.  In the game, there are several GContainers which take the form of blackholes slowing boucing around the screen.  There are also several "planets", which are GOvals that are pushed around the screen towards a destination.  I just added some code which should check for a collision between the blackholes and the planets.  However, according to a println command I put in, the blackholes and the planets are constantly overlapping, which I don't think is true.  

This is the code to check for collision between the black holes and the planets:

 
 public void checkBlackholeCollision(BlackholeGame blackhole, GOval planet){
        double distance = getDistanceOfBlackholeAndPlanet(blackhole, planet);
        double overlapped = (SIZE/2 +(blackhole.getWidth()/2) - distance);
        if (overlapped>0) {
            gameIsLost = true; 
        }
    }

Open in new window


This the code to get the distance between the two:

private double getDistanceOfBlackholeAndPlanet(BlackholeGame blackhole, GOval planet){
        return GMath.distance(blackhole.getX(), blackhole.getY(), planet.getX() + SIZE/2, planet.getY() + SIZE/2);
    }

Open in new window


This is the code for the blackhole's general collision:

public void checkCollision(BlackholeGame blackhole) {
        double x = blackhole.getX();
        double y = blackhole.getY();
        double size = blackhole.getWidth();
  

Open in new window

0

Java

98K

Solutions

32K

Contributors

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