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 am having problem with this quiz basic Java program (see code). This is my first program and any help what be appreciated. Thanks in advance.

public class Quiz{
public static void main (String args[])
     System.out.println ("Welcome to the Quiz Game!");
     int ans2=1;    
       System.out.println ("The instructions are: you will be given one type of topic,");
       System.out.println ("The topic will have 3 multiple choice questions");
       System.out.println ("If you get one wrong you start from the beginning.");
       System.out.println ("If you get them all right you will win");
 int ans1=Keyboard.readInt();
           System.out.println ("First question: How many players are there in 1 football team?");
           System.out.println ("9");
           System.out.println ("10");
           System.out.println ("11");
        System.out.println ("Question 2: Which of these teams play in the Premeir League?");
        System.out.println ("press 1 for Juventus");
        System.out.println ("press 2 for Chelsea");
        System.out.println ("press 3 for PSG");
if((ans1==11 & ans1==2));
        System.out.println ("Correct");
        System.out.println ("Question 3: How do you score?");
        System.out.println ("press 1 if by kicking the ball into the net");
        System.out.println ("press 2 if by throwing the ball into the net");
        System.out.println ("press…
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

I need to process/clean a csv file. The csv file looks like below
"Symbol","Date","Expiry","Option Type","Strike Price","Open","High","Low","Close","LTP","Settle Price","No. of contracts","Turnover in Lacs","Premium Turnover in Lacs","Open Int","Change in OI","Underlying Value"

Open in new window

I am using open csv. How do i remove the double quotes in the data so that it looks like below.

Symbol , Date, Expiry, Option Type, Strike Price, Open, High, Low, Close, LTP, Settle Price, No. of contracts, Turnover in Lacs, Premium Turnover in Lacs, Open Int, Change in OI, Underlying Value
STOCKA , 03-Oct-2017 , 30-Nov-2017 , PE , 11450 , 0, 0, 0, 1309.85, 0, 1477.35, 0, 0, 0, 0, 0, 9859.5
STOCKB, 03-Oct-2017 , 30-Nov-2017 , PE , 11450 , 0, 0, 0, 1301.35, 0, 1477.35, 0, 0, 0, 0, 0, 9899.5
STOCKC , 03-Oct-2017 , 30-Nov-2017 , PE , 11450 , 0, 0, 0, 1309.95, 0, 1477.35, 0, 0, 0, 0, 0, 9849.5
STOCKD , 03-Oct-2017 , 30-Nov-2017 , PE , 11450 , 0, 0, 0, 1300.05, 0, 1477.35, 0, 0, 0, 0, 0, 9859.5

Open in new window

Hello experts,
 I have created a browser in visual c#, the simplest following the examples over the internet.
but I keep getting this message: " An error has occurred in the script of this page...
object does not support property or method 'aDDEventListener' "

but on main browsers like IE and chrome, this error message does not appear.

NOw I have already tried the following three methods to no effect:

Method 1:
1.      Click Start, and then click Run.
2.      In the Open box, type Regsvr32 urlmon.dll, and then click OK.
3.      When prompted with the DllRegisterServer in the urlmon.dll succeeded message, click OK.

Method 2:
1.      Open the Java Virtual Machine. To do so, visit the following Java Website:
Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
2.      Close all instances of Internet Explorer.
3.      Click Start, click Control Panel, and then double-click Internet Options.
4.      Click the Advanced tab.
5.      Under Browsing, click to clear the Enable third-party browser extensions (requires a restart) check box.
6.      Restart Internet Explorer.

Method 3:
1.      Open Internet Explorer.
2.      Click Tools, and click Internet Options.
3.      Click the Advanced tab.
4.      Under Browsing, click to select the Disable Script Debugging checkbox.
5.      Click OK to close all windows, and then restart …
i have generated pdf successfully on server and downloaded successful too when i am going to open it display nothing.

While Accessing PDF File from Server Side which Generated by Java Code, it is Displaying all contents properly. but not displaying any content when it downloaded at Client Side through Following Code.

#Java Code with Play Framework

public Result generatePDF(){
		DynamicForm form = Form.form().bindFromRequest();
		if ( == 0) {
			return badRequest("Data is Missing from Request !!!");
			String jsonData = form.get("jsonData");

			File dir = new File("tmp");
			String FileName = "tmp/ChartData" + System.currentTimeMillis() + ".pdf";
			Document doc = new Document();
			PdfWriter.getInstance(doc, new FileOutputStream(FileName));;
			PdfPTable table = null;
			JSONObject json = new JSONObject(jsonData);
			BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.EMBEDDED);
			Font font = new Font(bf, 8);
			Font fontCell = new Font(bf, 10);
				JSONArray arr = json.getJSONArray("columns");
				int size = arr.length();
				table = new PdfPTable(size);
				for(int i=0;i<arr.length();i++){
					table.addCell(new PdfPCell(new Phrase(arr.getString(i), fontCell)));
					JSONArray rows = json.getJSONArray("rows");

Open in new window

i am creating a project in eclipse using gradle:but when i updating dependency in build.gradle  i got Exception

org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from ''.
	at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution.getToolingImplementationClasspath(

Open in new window

i cheak all suggestion like proxy setting .gradle file but same Exception is there:can u help me
I am given a document that has 72 pages worth of employees, salaries, and jobs. I know how to scan it in and I am putting everyone that works for the same company together. This is in the 4 word in each sentence. I am using if statements to see if it equals "police" that it will write to a file police. I am stuck on how to write the array back to a string and then put it in a file that is designated for each company.

How do I reprint the array I checked as the string it started as?
How do I get it to print to a document called "police" or "Engineer"?

File does not have to be created before hand supposedly.

I need a progra to sort and put them in different files with what company they are workig for.
If anyone could help me understand why the convert() method code is producing this output in patientout.json:

        "patientid": "1235",
        "sex": "female",
        "name": "Jane Smith",
        "state": "OH",
        "age": 47
        "patientid": "1235",
        "sex": "female",
        "name": "Jane Smith",
        "state": "OH",
        "age": 47

Open in new window

Instead of this output:
              "patientid": 1234,
              "sex": "male",
              "state": "MI",
              "name": "John Smith",
              "age": 55
              "patientid": 1235,
              "sex": "female",
              "state": "OH",
              "name": "Jane Smith",
              "age": 45

Open in new window

I would appreciate it.

The patientin.xml input file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
       <name>John Smith</name>
       <name>Jane Smith</name>

Open in new window

The convert() method can be found in file
Websphere 8.5.5 :- Launch Client (Bypass the Authentication)
I want to bypass the authentication.
My soap.client.props details :-{xor}HggrAC8KZCgXa2QmZS5o

opt/was/85/AppServer/profiles/node1/bin/ /tciservices/gts/fehComm/FehFcsPutCli.ear -CCverbose=false -CCBootstrapPort=9813 -CCexitVM=true
IBM WebSphere Application Server, Release 8.5
Java EE Application Client Tool
Copyright IBM Corp., 1997-2011
WSCL0012I: Processing command line arguments.
WSCL0013I: Initializing the Java EE Application Client Environment.
[5/22/18 10:19:15:205 EDT] 00000001  W UOW=null org=IBM prod=WebSphere component=Application Server thread=[P=755014:O=0:CT]
          CWPKI0041W: One or more key stores are using the default password.
WSCL0035I: Initialization of the Java EE Application Client Environment has completed.
WSCL0014I: Invoking the Application Client class
Starting FehFcsPutCli --> main is being executed
Connecting to EJB server...
Realm/Cell Name: defaultWIMFileBasedRealm
User Identity: XXXXXXX
User Password:                                                                                                                                                    Processing...
Execution complete ET(ms):16
I'm using Google Api to integrate google login in my Android App. It works very well, at the moment, and I'm able to retrieve the user name and the email, but I'm not able to retrieve the user profile pic.

When I try to execute

Open in new window

, I always get "null". I set the profile picture in my google account, so I'm pretty sure I should get something different from "null". Obviously, photo_url is declared as Uri.

As I read on Google Developers, I added .requestProfile() to retrieve information about the user profile, but I always get null for the profile photo.

How can I solve the problem?

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)

        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);


    private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
            try {
                GoogleSignInAccount account = completedTask.getResult(ApiException.class);
                googleName = account.getDisplayName();
                goofleEmail = account.getEmail();
                photo_url = account.getPhotoUrl();
                Log.w(TAG, "test url" + photo_url);


Open in new window

I am trying to get started with a java application
I have already installed java, apache & maven but on the following import commands

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.builder.SpringApplicationBuilder;

I get package or.springframework.boot does not exist. I believe it ts part of Maven
Any ideas anyone?
Free Tool: Subnet Calculator
LVL 12
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I have an activity where the user can update some data related to his profile (for example, his name) and he can also upload a new profile image.

After the update operation, the user is redirected to a new activity. The problem is that when the user comes back to his profile activity, the showed image is still the old one and not the new one while the name updated correctly.

In order to see the new profile image, the user needs to close the app and open is again.

How can I solve this problem? I use a function updateInfo(), but it seems to not work as I would like.

Can you help me, please?

public class ProfileActivity extends BaseActivity implements ProfileView {

    ImageView p_avatar;
    ImageButton ibBack;
    TextView txtTitle;
    ImageButton ibRight;
    Toolbar toolbar;
    EditText etFullname;
    EditText etEmail;
    Button btnUpdate;
    TextView txtLogout;
    LinearLayout llMain;

    private static final String TAG = "ProfileActivity";
    private String userName = null, userEmail = null;
    private ProfilePresenter profilePresenter;
    private Dialog dialog;
    Bitmap FixBitmap;
    Bitmap bitmap_to_save;
    ImageView ShowSelectedImage;

Open in new window

Can anyone suggest the least ‘intrusive’ way of adding a text label to a JSlider ? Thanks for any pointers.
I'm using Android Studio and I would like to be able to pickup am image from the gallery, resize it and make it fit inside a rounded square (of about 300x300px) by maintening the correct aspect ratio. At the moment, I'm able to resize it and display it as a circle with this code:

FixBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                bitmap_to_save = scaleBitmapAndKeepRation(FixBitmap, 320, 320);

                RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap_to_save);

Open in new window

However, I would like to know if it is possible to make the bitmap look like my attached image. Moreover, it would be important for me to resize the image without losing the original aspect ratio.

It is not exactly a well square rounded figure, so I'm not sure that it is possible to do it in Android.

I hope you can help me, thanks!

EDIT: I'm using Picasso library for the moment, and it seems to work. Anyway, I would like to keep always the same picture size (300x300 px) and the aspect ratio. How can I do it?

I have a xml  like <url href=""></url>
i am using dom parser to cheak both url should match or not ( and
so i am Writing The code is :
String s=""; Document doc = dBuilder.parse(inputFile); NodeList nodeList= doc.getElementsByTagName("url"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if(node.getNodeName().equals("url")){//Reconfirm after that getting content Element element = (Element) node; s=element.getTextContent(); String s2=element.getAttribute("href"). }So can u help me how to get href content so that i can cheak both value

I am taking a JAVA class and the instructor has asked us to write some code with a car called "Car Class".  For the first part we are supposed to  Write a class named Car that has the following member variables:
This part was found on the Internet. The part that has me confused is Part 2 where we need to create a GUI (see after code for instructions) farther down .

      • year. An int that holds the car’s model year.
      • make. A string object that  holds the make of the car.
      • speed. An int that  holds the car’s current  speed.
      In addition, the class should have the following member functions.

      • Constructor. The constructor should accept the car’s year and make as arguments and  assign

      these  values  to  the  object’s  year and  make member   variables.   The constructor should

      initialize the speed member variable to 0.

      • Accessors. Appropriate accessors functions  should  be created  to allow  values to

      be retrieved  from an object’s year,  make, and speed member  variables.

      • accelerate. The  accelerate function   should   add   5  to  the  speed member variable  each

      time it is called.

      • brake. The  brake function  should  subtract 5 from  the  speed member  variable each time it is


      Demonstrate the class in a program that creates a Car object, and then calls the accelerate

      function  five times. After each call to the accelerate function,  get the current  speed of the car

      and  display  it. Then,  call the brake …
i want to make inside json Array list inside array list

      "groupInformationKey": 6,
      "groupName": "PortalAdministrator",
      "subGroups": [{
      "groupInformationKey": 52,
      "groupName": "axfxf",
      "subGroups": [{
      "groupInformationKey": 53,
      "groupName": "axx",
      "subGroups": [{groupInformationKey": 54,
      "groupName": "ox",
      "subGroups": null,
      "subNestedGroup": null,

how to make with array list and pojo with sub group inside subgroup and so on
how to disable tlsv1.0 and tlsv1.1 for wildfly/jboss 10.

Tried to enable tlsv1.2:
added enabled-protocols="TLSv1.2" to http-listener in standalone.xml.  It has thrown below error.

 Message: WFLYCTL0376: Unexpected attribute 'enabled-protocols' encountered. Valid attributes are: 'receive-buffer, send-buffer, tcp-backlog, tcp-keep-alive, read-timeout, write-timeout, max-connections, socket-binding, worker, buffer-pool, enabled, resolve-peer-address, max-post-size, buffer-pipelined-data, max-header-size, max-parameters, max-headers, max-cookies, allow-encoded-slash, decode-url, url-charset, always-set-keep-alive, max-buffered-request-size, record-request-start-time, allow-equals-in-cookie-value, no-request-timeout, request-parse-timeout, disallowed-methods, secure, certificate-forwarding, redirect-socket, proxy-address-forwarding, enable-http2, http2-enable-push, http2-header-table-size, http2-initial-window-size, http2-max-concurrent-streams, http2-max-frame-size, http2-max-header-list-size'

Please suggest
How to make api for this code in java using jersey.

post request username and i want user full name in return in json form.

package example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Somthing {
     public static void main(String[] args) throws SQLException, ClassNotFoundException {
		Connection conn = DriverManager.getConnection("");
                PreparedStatement statement =  conn.prepareStatement("SELECT userfullname From this where username = 'raj'");
                ResultSet result = statement.executeQuery();
                while ( {
                 String s =  result.getString("usefull_name");

Open in new window

The following error pops up when ever I write a program. What do I do.
The type cannot be resolved. It is indirectly
       referenced from required .class files
Free Tool: ZipGrep
LVL 12
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Trying to write a ClientBuilder based method (Java/selenium tool) that handles the following condition: The Request Body for this api should be of type multipart/form-data and it should have a boundary differentiated between file attached to form and form fields

I have done the mutli Part Content in c# but the group needs to be written in Java. Here's the c# code that works for creating the request body. I just having some mental blocks writting the Java HTTP Client version (could not find any realistic samples out there)

Note: I trying to upload an application/msi or application/ms-dos-exec file via the form. Here's my c# code
		 MultipartFormDataContent multiPartContent = new
		 MultipartFormDataContent("----WebKitFormBoundaryliUiaMuaEcUBLr3A"); ByteArrayContent byteArrayContent = new
		 ByteArrayContent(LogoRequest.Content); byteArrayContent.Headers.Add("Content-Type", "image/png"); String
		 FileName = LogoRequest.Name; String ContentDispositionStr = "form-data; name=" + "\"logoImageFile\"" +"; " +
		 "filename=" + FileName; byteArrayContent.Headers.Add("Content-Disposition", ContentDispositionStr);
		 multiPartContent.Add(byteArrayContent); requestMessage.Content = multiPartContent;

Open in new window

i am getting an error " error while writing <anonymous MyThread$1>: Access is denied" while compiling the below code"
import java.lang.*;
class MyThread
    public static void main(String[] args)
        //Here we are using Anonymous Inner class
        //that implements a interface i.e. Here Runnable interface
        Runnable r = new Runnable()
            public void run()
                System.out.println("Child Thread");
        Thread t = new Thread(r);
        System.out.println("Main Thread");
what is the reason for the error
We have a large number of classes using JAXB for serialization and have not employed any validations for them during marshaling or unmarshalling process. Been exploring on JAXB in built mechanism for validation using set schema method. Now since I have a large number of JAXB model classes, generating schema for bulk of classes would result in complex schema. Trying to figure out to see if there is an ideal option through which validation can be performed for a specific class only in the schema and ignore the rest ?

I have the following lines of code,

    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema;

    JAXBContext jc;
    try {
        jc = JAXBContext.newInstance(MyClass.class);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        schema = sf.newSchema(new File("c:\\schema1.xsd"));
        unmarshaller.setEventHandler(new ValidationEventHandler() {

            public boolean handleEvent(ValidationEvent event) {
                if (event == null) {
                    return true;
                String line = "unknown"; //$NON-NLS-1$
                String col = "unknown"; //$NON-NLS-1$
                ValidationEventLocator locator = event.getLocator();
                if (locator != null) {
                    line = Integer.toString(locator.getLineNumber());
                    col = 

Open in new window

Getting error "SSLHandshakeException : unable to find valid certification to requested" while setting up  Properties setup for sandbox
HelIo to the experts

I created a spring boot application which uses the "@RestController Annotation" to generate an "ArrayList" as JSON. This will look like this:

[{"id":2374273, "url": ""}, {"id":2374274, "url": ""}]

Open in new window

However, the output should be as follows:

{"urls": [{"id":2374273, "url": ""}, {"id":2374274, "url": ""}]}

Open in new window

That means the JSON array should have an array name (name = "urls") in the output.

How can I solve this?

how to make this type of api in java using jersey and get value from mssql server.






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.