Java

99K

Solutions

33K

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

when we go to eclipse market place vs when we go
install new software option under eclise-->help

please advise
0
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

objectaid ul plugin now working

i went to eclipse -->help--->install new software

then i put url
http://www.objectaid.net/update
it brings windwo with saying
Add Repository
with 3 text boxes
Name
Location
not sure what to give above text boxes
after some times says
it says coulld find
http://www.objectaid.net/update

please advise
0
What's the meaning for the following Java statement  ? Is there any special meaning for "<>" ?

Thx


ArrayList<HashMap<String,String>> arrayList=new ArrayList<>();

HashMap<String,String> hashMap=new HashMap<>()
0
What are signed Jars ?
Why a signed Jar is needed?
When a signed jar needs to be created?
How to create a signed jar?
How the client will be benefited with signed jar?
What will happen when a jar is not signed?
How to create or build a signed jar?
Examples to build a signed jar from scratch?
In some application, after doing java changes, the client is requesting to build the signed jars for the client libraries changed?
How to debug errors during lauching signed jars or exceptions on building or running a signed jar?
0
Which on is the best tool for mobile web applications/apps (Python or Java or asp.net)
0
Can someone explain the following aspects of the given function?
    Why does it use both public and private?
    The steps in which this function is executed.


   
    public class MyData{
        private boolean show_state;
        private int switch_num;
        private Date lastDate;
        public MyData(boolean show_state, int switch_num, Date lastDate){
            this.show_state = show_state;
            this.switch_num = switch_num;
            this.lastDate = lastDate;
        }
        public String getShow_State(){
            return show_state? "show":"hide";
        }
        public int getSwitch_num(){
            return switch_num;
        }
        public Date getLastDate(){
            return lastDate;
        }
        public String toString(){
            SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss");
            String date = format.format(getLastDate());
            return String.valueOf(getShow_State()) + "\n" + String.valueOf(getSwitch_num()) + "\n" + date;
        }

Open in new window


******* Edited ********
0
Hello Experts,

I'm trying to install Java 8 on my Ubuntu 16.04 machine.

I'm very new to linux.

I'm presented with the following screens but I don't know what how to select 'Yes' to accept the agreement.

Very simple question, I know, but I really don't know.



0
Below are the couple of questions which needs help regarding cookie

1. I'm developing a standalone jar which access a http site inside the code. When i access the http site will the cookie will be stored in the client machine ??
2. When the cookie will be saved in client's machine ?
3. The cookie will be stored only when we access web application via browser or via any library and executing http request
4. When and how the cookie can be enabled or disabled in a client's machine.

Thanks.
0
I have 1 java web service and 1 spring batch job process which access same Oracle database server. Oracle DB is installed on Linux VM. Both use spring JDBC template for database operations. When I run both simultaneously I start getting "The Network Adapter could not establish the connection" error. We also see "ORA-00018.Maximum number of sessions exceed" exception after few seconds.  If I run them standalone, I don't get these error. Earlier everything was working fine even while running them together. What might have changed? What could be the reason for this error? What should I check?
0
Hi
i have a problem in xml parocessing in java using dom,it is my sample xml file
<titleGroup>

    <title type="main">Magnetic bead assisted labeling of antibodies at nanogram scale<link xml:id="pmic201300283-note-0001"/></title>

    <title type="tocForm">Magnetic bead assisted labeling of antibodies at nanogram scale</title>

    <title type="shortAuthors">M. Dezfouli et al.</title>

</titleGroup>

Open in new window

in this file if tocform from article tag then u Read xml file and match the content from main :if tocForm then match else ignore i am try this code
 NodeList nl = doc.getElementsByTagName("creators");
        for(int i=0;i<nl.getLength();i++)
        {
            Node node=nl.item(i);
            NodeList nl1=node.getChildNodes();
            for(int j=0;j<nl1.getLength();j++)
            {
                Node node1=nl1.item(j);
            
            if(node1.getNodeName().equals("title"))
            {
                Element e=(Element)node1;
            if(e.getAttribute("type").equals("main"))
            {
                String s=e.getTextContent();
                 al.add(s);//Read content from main section
                
            }
           if(e.getAttribute("type").equals("tocForm"))
            {
             String s=e.getTextContent();
             al1.add(s);//read content from TocFrom section
             }
            }
            if(al.containsAll(al1))
            {//do  something
            
        }

Open in new window

0
Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Java usage vs Javascript usage.

If I undestand:

--- knowing Java  you can develop Applications that interacts with Databases. I am not sure knowing Java by itself if you can develop Dynamic Web Applications that interacts with Databases and fetch the results.( I mean probably you will have to learn other languages too, such as HTML, JSS,etc..)

---knowing Javascript what kind of advantage you get over know just Java ? I believe JavaScripts also interacts with Databases on the server and fetch the result and render the result to end user via the browser.

so it sounds to me, Java can be used for Non Web Application. JavaScript for Web Application.

If that's the case it sounds to me that knowing Java Scripts is more useful that knowing Java, Web Apps are much more in demand.


Any Expert to shade some lights on that?

Thank you
0
Abstract Class in Java

abstract class Animal{
   //abstract method
   public abstract void sound();
}
//Dog class extends Animal class
public class Dog extends Animal{

   public void sound(){
      System.out.println("Woof");
   }
   public static void main(String args[]){
      Animal obj = new Dog();
      obj.sound();
   }
}


in the Example above, I thought you cannot create and Object from from an Abstract Class, as it is done here:
Animal obj = new Dog();

**Unless I missunderstood the term:
Abstract classes cannot be instantiated

Can someone Help Explain it ?

Thank you
0
I am working on a project where I need to build a Java application. Years ago on an old laptop, I downloaded and installed NetBeans IDE and really liked it. Anyway, I am looking to get up and running pretty fast. Can someone give me some steps to follow. This time i would like to use Eclipse. Is their one installation package that I can just run, and it will install the Java Sdk ,and then eclipse? Or do I need to first install the Java jdk, and go to a different site for the Eclipse download?

If there is not just one installation package I can download. Possibly someone can list the steps to get Java and an IDE up and running on my new laptop. I am not looking for detailed instructions. Just a link or two to one or more websites to download and install the Java  on my Windows 10 laptop.
0
Hi,

I have an excel file which would contains around 20-30 millions records every time user uploads the same,frequency of upload would be 4-5 times on daily basis (by different users).
Application which is built on java, spring 3 and SQL server as back end.

Just need to know how to process/read the file ( reading the excel file cell by cell and storing in database) in an efficient manner which would not allow user to wait much.
0
I know how to use Binary Search for numeric values. However, I need to use Binary Search for searching the name from an already sorted array of string.
See line 63
//Updation of mobile nos. for n customers
import java.util.Scanner;
class MobileNo
{
     private long mobNo[];
     private int n;
     private String name[];
     void getInput()
     {
         Scanner sc = new Scanner(System.in);
         do
         {
             System.out.print("Enter the no. of customers: ");
             n = sc.nextInt();
         }
         while(n <= 0);
         System.out.println("Enter the customer names and mobile nos: ");
         name = new String[n];
         mobNo = new long[n];
         for(int i = 0; i < n; i++)
         {
             System.out.println("Customer - "+(i + 1)+":- ");
             if(sc.hasNextLine())
             sc.nextLine();//drains Scanner of Line Feeds
             name[i] = sc.nextLine();
             do
             {
                 mobNo[i] = sc.nextLong();
                 if(mobNo[i] < 1000000000l || mobNo[i] > 9999999999l)
                 System.out.println("Give a 10 digit no!");
             }
             while(mobNo[i] < 1000000000l || mobNo[i] > 9999999999l);
         }
     }
     void sort()
     {
         String temp;
         long tempNo;
         for (int i = 0; i < n; i++) 
         {
               for (int j = i + 1; j < n; j++) 
               {
                   if (name[i].compareTo(name[j])>0) 
                  

Open in new window

0
This is using a SuSE enterprise linux 11 sp3 server. This is a application using java. The problem is on the memory, only little memory available out of 64 GB. If we do a " top", we found that quite a number of java processes taking the memory. Besides 64 gb ram, we also used the exact 64 gb swap. We found that swap memory still largely not in use. Please see the attached file for the result of top command.

What is puzzling us is, another system with the identical hardware, specs, os, and load, doesn't faced the same issue as this system did. How to make more memory available especially for the physical RAM?

Thanks in advance.
exchange_top---Copy.xlsx
vmstat_free-m.PNG
0
I am having problem with this Java program, where Java seems to be skipping the for loop within indexOfMin(startIndex) method on line 28. For this, on line 38, the System.out.println("Index of Smallest Integer = "+index.indexOfMin(0)); prints 0 always. How can I fix this issue?
//Selection Sort
import java.util.Scanner;
class SelectSort
{
     private int arr[], n;
     public SelectSort()
     {
         n = 5;
         arr = new int[n];
     }
     public void getElements()
     {
         Scanner sc = new Scanner(System.in);
         System.out.println("Enter the elements of the array(5 integers): ");
         for(int i = 0; i < n; i++)
         arr[i] = sc.nextInt();
     }
     public void showElements()
     {
         System.out.println("Current Array:- ");
         for(int i = 0; i < n; i++)
         System.out.print(arr[i] + " ");
         System.out.println();
     }
     public int indexOfMin(int startIndex)//problem with this method
     {
         int lastIndex = n - 1, indexofmin = 0, min = arr[0];
         for(int i = startIndex; i <= lastIndex; i++)//Java seems to be skipping the for loop
         {
             if(min > arr[i])
             indexofmin = i;
         }
         return indexofmin;
     }
     void SelectionSort()
     {
        SelectSort index = new SelectSort();
        System.out.println("Index of Smallest Integer = "+index.indexOfMin(0));//Index of smallest integer always displays 0
        int min, pos;
        for(int i = 0; 

Open in new window

0
HttpURLConnection getInputStream throws below errors sometimes -

java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 500

Open in new window


Here is the part of callstack -

09:05:02,198 ERROR [stderr] (http-/111.222.333.444:11800) java.io.IOException: Server returned HTTP response code: 500 for URL: https://111.222.333.444:11800/xyz/myapp/3.0/urn:name:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
09:05:02,198 ERROR [stderr] (http-/111.222.333.444:11800)   at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1628)
09:05:02,199 ERROR [stderr] (http-/111.222.333.444:11800)   at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)

Open in new window


This is a how my code looks like. This is not a client code. This runs on server like Tomcat -

private void getResult(HttpURLConnection urlconnection,
            String result) {
        BufferedReader bufferedReader;
        String line;
        try {

            bufferedReader = new BufferedReader(new InputStreamReader(
                    urlconnection.getInputStream()));

            while ((line = bufferedReader.readLine()) != null) {
                result += line;
            }

            bufferedReader.close();
        } catch (Exception ex) {
            String error = String.format("Invalid InputStream, %s",
                    ex.getMessage());
        }

        return;

}

Open in new window


The URL that I have prepared looks like below -

 https://111.222.333.444:11800/xyz/myapp/3.0/urn:name:ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ

Open in new window


Can this be java problem or server is responsible for this? What could be the problem?
0
How can I format a youtube link in a web page so that, if it is clicked on mobile browser, it opens by browser instead of the youtube app?
0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I am attempting to set up Liquibase 3.6.1 on a solaris VM.
My JRE is 1.6.0_151-b10.
My Liquibase.properties file is configured as follows:
driver:oracle.jdbc.OracleDriver  
classpath:/export/home/oracle/Liquibase/lib/OJDBC-Full/ojdbc6.jar  
url:jdbc:oracle:thin:@db:port/instance  
username:uname  
password:pword  

Open in new window

When calling "./Liquibase --version" (for example), I get an error.
Exception in thread "main" java.lang.UnsupportedClassVersionError: Liquibase/integration/commandline/Main : Unsupported major.minor version 51.0
I have looked around for another post relating to a similar issue with java version/Liquibase issue. The closest I have found was relating to the "api" not being compatible with the version of java installed (version or release or update).

Also posted on Stack Exchange
0
Hi Experts,

List<String> list = new ArrayList<String>();
            list.add("gh_123");
            list.add("sg_456");
            list.add("hk_789");
            list.add("ke_968");
            
            
O/P:
i have to iterate the list
split the string into two  parts as below
String countries = 'gh','sg','hk','ke';
int custId = 123,456,789,968;
0
I'm trying to make a SOAP connection to a remote server that is enforcing TLS 1.2.  I'm getting a "SECURITY VIOLATION" error, which is due to the connection not going over TLS (according to the remote host).  

I tried adding SSLContext, but that doesn't seem to do the trick.  Can anyone point me in the right direction?




    private static void callSoapWebService(String soapEndpointUrl, String soapAction) {
        try {
            SSLContext sc = SSLContext.getInstance("TLSv1.2");
            sc.init(null, null, new java.security.SecureRandom());
            // Create SOAP Connection
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();

            // Send SOAP Message to SOAP Server
            SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(soapAction), soapEndpointUrl);

            // Print the SOAP Response
            System.out.println("Response SOAP Message:");
            soapResponse.writeTo(System.out);
            System.out.println();

            soapConnection.close();
        } catch (Exception e) {
            System.err.println("\nError occurred while sending SOAP Request to Server!\nMake sure you have the correct endpoint URL and SOAPAction!\n");
            e.printStackTrace();
        }
    }
0
In the code given below, Java is skipping the line name = sc.nextLine() for 2nd iteration of for loop, but it works fine and doesn't skip the line for the 1st iteration. What am I doing wrong and how can I prevent Java from skipping this line?
//Calculate Electricity Bill for n customers
import java.util.Scanner;
class ElectricityBill
{
    private String name;
    private int n, units;
    private double chrg;
    void getInput()
    {
        Scanner sc = new Scanner(System.in);
        do
        {
            System.out.print("Enter the no. of customers: ");
            n = sc.nextInt();
        }
        while(n <= 0);
    }
    void computeAndDisplayBill()
    {
        Scanner sc = new Scanner(System.in);
        for(int i = 1; i <= n; i++)
        {
            System.out.print("Enter the name of customer - "+i+": ");
            name = sc.nextLine();//Java skips this line for 2nd iteration of for loop
            do
            {
                System.out.print("Enter the no. of unit(s) consumed: ");
                units = sc.nextInt();
            }
            while(units <= 0);
            if(units <= 50)
            chrg = 0.5*units;
            else if(units > 50 && units <= (120+50))
            chrg = (0.5*50)+(0.85*(units-50));
            else if(units > (120+50) && units <= (130+120+50))
            chrg = (0.5*50)+(0.85*120)+(1.2*(units-(120+50)));
            else if(units > 300)
            chrg = 

Open in new window

0
I want to set an attribute, on a class, which is in a .jar file, but the .jar file is signed, so I can't modify the .jar file.

And I can't (without great difficulty) modify the code that calls the class in this .jar file.

However, I can specify which .jar file the calling code uses, so I'm wondering if there's a way I can wedge in my own .jar file, which then acts as an intermediary and calls the real .jar file, and sets that one Boolean attribute to true for that one class I'm interested in.

CALLING PROGRAM → my.jar → Saxon-HE-9.8.0-5.jar

The way it's currently set up:

CALLING PROGRAM → Saxon-HE-9.8.0-5.jar

and CALLING PROGRAM makes the following call:
TransformerFactory transformerFactory = TransformerFactory.newInstance();

Open in new window

At this point if I could edit the calling program code, I would just add the following line:
transformerFactory.setAttribute("http://saxon.sf.net/feature/ignoreSAXSourceParser", true);

Open in new window

But I don't have that luxury.

If I diverted the calling program to use my.jar instead of the real Saxon-HE-9.8.0-5.jar, is there an easy way to do that and make just one small modification?

CALLING PROGRAM → my.jar → Saxon-HE-9.8.0-5.jar

Or am I now stuck with having to implement the entire Saxon interface in my.jar, which may or may not be huge.
 
(I seem to recall some Design Pattern about this.)

My idea would be to override TransformerFactory.newInstance(); and slide in my one line of code to set that one attribute.


Is this even possible if I pursue this course? Or, is there another easier way?
0
I have a Java .jar file (Saxon-HE-9.8.0-7.jar). I want to modify this .jar file.

My first attempt was to add a new class to it. All seemed to go well, until I tested it, and the calling program insisted it could not find the new class.

This was my new class:

package net.sf.saxon;

public class TransformerFactoryImpl2 extends TransformerFactoryImpl
{
	public TransformerFactoryImpl2()
	{
	    this.setAttribute("http://saxon.sf.net/feature/ignoreSAXSourceParser", true);
	}
}

Open in new window


I compiled it at a Windows Command Line using javac.exe

 java.exe -cp Saxon-HE-9.8.0-7.jar TransformerFactoryImpl2.java

Open in new window


This created file TransformerFactoryImpl2.class

Then I added this new class to the .jar file:

jar uf Saxon-HE-9.8.0-7.jar TransformerFactoryImpl2.class

Open in new window


Did I miss a step? Is there a manifest somewhere I need to add this new class to?


Since this approach did not work, my next idea was to modify the original class. I disassembled the original class, modified it, recompiled it using the same technique as above, then updated the jar file using the same technique as above. I then unzipped the resulting jar file, and found I had two copies of file TransformerFactoryImpl.class in two different places: the original class where it belonged in the net\sf\saxon directory, and my new class in the top level directory.


What step am I missing?
0

Java

99K

Solutions

33K

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.