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

HI Team ,

I am retrieving value from database through JDBC statement  my plsql query is below -

Select * from A union Select * from B.

but when i am retrieving value through JDBC statements its give null . when i am individually running query like Select * from A without using Union  its working fine and giving results but when i am using 2 query via Union its give Null. Please tell me where i m wrong .
0
Introduction to R
LVL 13
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Hello,
when defining a long variable. Why is number an int and not a long?

long number = 1000;

Open in new window


Why do I need a L

long number = 1000L;

Open in new window

0
Hi everyone,
I'm encountering a weird issue from Windows slave in Jenkins, I tried many solutions provided in Stackoverflow, but no luck. So I re-post my question here to looking for your support.

I just setup a new jenkins slave which is running Windows server 2012. I already installed jdk-8u221-windows-x64 and set Java_home, Path like below

C:\Users\Administrator>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_221\

C:\Users\Administrator>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\
Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\
Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Git\cmd;C:\Program Files\Ja
va\jdk1.8.0_221\\bin;C:\maven\bin;C:\maven\bin

Open in new window


However,build job running in this slave always complain that:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

Open in new window


Here is a slave node configuration:
Slave node configuration
In a Job build configuration, I selected (System) in JDK option. If I choose JDK 8 update 221, this build job run successfully, but I want to use a (System) JDK which will get from environment variable in this node, so I can switch to another slave node without changing the JDK option.
Job build configurationHowever, when I remote to this server, and open command prompt, cd to workspace folder of this project, let say: C:\jenkins_slave\workspace\project01\, then type the command: mvn clean install, it run without complain about jdk or jre as run from Jenkins. That's very surprise.

Any idea of what might be causing this? If you need more info, please let me know.
Thanks.
0
I'm trying to figure out how to serialize an array of java objects and post as json with jax-rs ClientBuilder using jersey and/or jackson.

I'm using the ClientBuilder to do a post. If for example you have an Arraylist of Car objects

List<Car> cars = new ArrayList<>();

Open in new window

And I want to do something like:

Response response = ClientBuilder
.newClient.target(url)
.request()
.accept(MediaType.APPLICATION_JSON)
.post(Entity.json(cars));

Open in new window

and post exactly this as the payload

[{"brand": "toyota"}]

Open in new window

How would I need to implement the Car object? And how would I need to setup my ClientBuilder chain properly?
0
Hello everyone.  It has been some time since I worked with Java on my laptop. I went to  FullStack Developer bootcamp but took a non-IT position after completion.  I want to get back into the IT arena.  Unfortunately, I need a little refresher working around in the editors/tools and running my projects. We used GitHub, Bash and Sublime.

Do you know of any consultants I can work with to get me goin again? I am in the Cleveland Ohio area.

Thanks,
Ed
0
hi,

I am reading:

https://www.oracle.com/technetwork/testcontent/jdbc-ch5-131209.pdf

https://docs.oracle.com/database/121/JJDBC/oraperf.htm#JJDBC28767

for Oracle prepared statement.

and I do not understand what it means as it says:

Starting from Oracle Database 12c Release 1 (12.1), Oracle update batching is deprecated. Oracle recommends that you use standard JDBC batching instead of Oracle update batching.

Open in new window


when I check standard JDBC batching it says:

The Oracle implementation of standard update batching does not implement true batching for generic statements and callable statements. Even though Oracle JDBC supports the use of standard batching for Statement and CallableStatement objects, you are[b][u] unlikely[/u][/b] to see performance improvement.

Open in new window


so in order to use a  REAL batch mode for PL/SQL prepare statement, what should I do ?

or it means must be handle in java library when calling:

...
Statement stmt = conn.createStatement();

stmt.addBatch("INSERT INTO emp VALUES(1000, 'Joe Jones')");
stmt.addBatch("INSERT INTO dept VALUES(260, 'Sales')");
stmt.addBatch("INSERT INTO emp_dept VALUES(1000, 260)");
...

Open in new window


?

then it still related to prepared statement ?
0
how to sequence or auto increment  in cassandra  from java /Spring code
0
Hi,

I have a question about Maven download (maven dependency plugin).

I have maven job (pom.xml) for download artefacts from antifactory (internally, but not in the local, remote site)

In this job there are about 10 files to be downloaded. Total cost 40 minutes. I run the job probably twice a day for new builds published to that artifactory from remote team.


We do have local artifactory, but the network between here to the remote artifactoy is not very good, so the sync is not working properly, and I don't think company will fix this in short time.

I am wondering is there a way from maven to download these artefacts parallel, in this case it will save time.

Here is an example of my pom,xml

 
<plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>database-scripts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.abc.eee</groupId>
                                    <artifactId>Database</artifactId>
                                    <version>${version}</version>
                                    <type>zip</type>
                                   

Open in new window

0
Hi Experts,

I am facing the below issue while hitting the REST service request from soapui.
java-1.8
soapui-5.5.0

Exception:
exception in thread "main" java.lang.assertionerror: failed generating bytecode

used below link for sample:
https://www.soapui.org/rest-testing/getting-started.html


Suggest me how to resolve this issue.
0
Hi, this is my first attempt to use Eclipse

I created the Hello World example and got the subject error. Here is my screen.My screen
0
Bootstrap 4: Exploring New Features
LVL 13
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hi Experts,

I am using soap webservices  to communicate to other application.
To connect soap webservice i have a Endpoint url.
i have to download the certificate from the EPUrl.

can some one suggest how to download the certificate from the browser.
0
When trying to open the Java Control Panel on a MAC (10.14.6) the Java icon appears in the Doc for about 5 seconds and then disappears.

in the console I see

default      10:02:23.784603 +0100      distnoted      register name: com.apple.nsquiet_safe_quit_give_reason object: net.java.openjdk.cmd token: f4277 pid: 1673
default      10:02:23.980889 +0100      hidd      Connection added: IOHIDEventSystemConnection uuid:421A6A31-396A-42FB-B50F-D17ABF143B1D pid:1673 process:java type:Passive entitlements:0x0 caller:HIToolbox: ___GetIOHIDEventSystemClient_block_invoke + 26 attributes:(null) inactive:1
default      10:02:24.024459 +0100      kernel      AGC:: [java pid:1673 mux-aware] starting, non-mux-aware app count 2 WS-ready 1 switch-state 0 IG FBs 0 EG FBs 1:1f power-state 0 3D idle HDA idle
default      10:02:24.024611 +0100      kernel      AGC:: [java pid:1673 non-mux-aware] starting, non-mux-aware app count 3 WS-ready 1 switch-state 0 IG FBs 0 EG FBs 1:1f power-state 0 3D idle HDA idle
default      10:02:26.979703 +0100      kernel      AGC:: [java pid 1673 non-mux-aware] exiting, non-mux-aware app count 2, runtime: 0:00:02.955
default      10:02:26.979747 +0100      hidd      Connection removed: IOHIDEventSystemConnection uuid:421A6A31-396A-42FB-B50F-D17ABF143B1D pid:1673 process:java type:Passive entitlements:0x0 caller:HIToolbox: ___GetIOHIDEventSystemClient_block_invoke + 26 attributes:(null) inactive:0
default      10:02:26.980125 +0100      kernel      AGC:: [java pid 1673 mux-aware] exiting, non-mux-aware app count 2, runtime: 0:00:02.955
default      …
0
What is the best way to introduce a new object to existing classes, in my project i have several classes and now i am implementing reporting and have to log some messages whenever a method execution is failed

Is it a good practice to create object of the new class in all the existing classes or is there any other way?

trying to minimize the code changes

Initial set of code

Class one{

public void method1() {

     try
     {
          //perform something
       }
       catch(Exception ex){
           S.o.p("some message")
        }
  }

public void method2() {

     try
     {
          //perform something
       }
       catch(Exception ex){
           S.o.p("some message")
        }
  }

}



Class Two {

public void method1() {

     try
     {
          //perform something
       }
       catch(Exception ex){
           S.o.p("some message")
        }
  }

public void method2() {

     try
     {
          //perform something
       }
       catch(Exception ex){
           S.o.p("some message")
        }
  }

}

class Test
{
   public static void main(String args[]){
         One o = new One(); 
         o.method1();
         o.method2();

         Two t = new Two();
        t.method1();
        t.method2()
   }

}

Open in new window


Code after introducing a new Class (for Ex: Logging for reporting)

   

Class One{

    Private ReportLogger report;

    Public One(Report report)
    { 
         this.report = report;
     }
 

Open in new window

0
Hi
I am ready to get some of my javascript game code onto my phone.
I'm hoping it's relatively straightforward like simply making an HTML canvas and popping it in..
Too much to hope for?
This is some simple javascript showing object drawing on a scene. code in text area below, and the link

URL at javascript at the bottom of this page
 ...
var canvas = document.getElementById("game-layer");
var context = canvas.getContext("2d");

context.fillStyle = "gray";
context.fillRect(0, 0, canvas.width, canvas.height);

context.fillStyle = "red";
context.fillRect(5, 5, 10, 15);
context.fillStyle = "blue";
context.fillRect(25, 25, 20, 20);
context.fillStyle = "green";
context.fillRect(50, 50, 20, 40);

Open in new window


Thanks
0
we use Payara on Centos 7 Java8 with Oracle. We have enabled the JDBC cache. Now we get the ORA-01438 error. If we turn off the cache we don't get the error anymore, the application is very slow. Does anyone have the experience for this constellation?
This the Parameter.
<protocol name="http-listener-1">
   <http max-connections="500" timeout-seconds="60" default-virtual-server="server">
        <file-cache enabled="true" max-age-seconds="3600"></file-cache>
   </http>  
</protocol>

Open in new window

0
HI,
I have a question about rest call.  I have a rest call, which with token, but I got a status code :999. why it will return 999?
There is no response come back.

Thanks
0
testwsdl.wsdlHI, I am trying to create a handler class to modify the namespace of the  response that come from soap web service.
If I create a  handleMessage() method, where should I call this handleMessage and what I should pass in as a SOAPMessageContext if I only have a respose object?

public boolean handleMessage(SOAPMessageContext smc) {

    Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    if (outboundProperty.booleanValue()) {
   
        try {
            SOAPMessage msg = smc.getMessage();
            SOAPPart sp = msg.getSOAPPart();

            sp.getEnvelope().removeNamespaceDeclaration("soap");

            sp.getEnvelope().setPrefix("SOAP-ENV");
            sp.getEnvelope().getBody().setPrefix("SOAP-ENV");
            sp.getEnvelope().getHeader().setPrefix("SOAP-ENV");

            smc.setMessage(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
}
0
I need help to configure a RHEL 6.10 to start Tomcat9 on reboot. I have successfully installed Tomcat9 from a binary and am able to start and stop Tomcat manually using the /bin/startup.sh script.
I have added /etc/init.d/tomcat9 file that I have attached.
After rebooting the server and typing service tomcat9 status, it returns "java dead but pid file exists"
I know Java isn't "dead". I can run ps aux | grep java and it returns several processes.

If I type service tomcat9 start, the command returns
root: Starting Tomcat
This account is currently not available.


If I type service tomcat9 restart, the command returns
root: java is not running.

The user tomcat does exist and belongs to the group tomcat.
I created the user tomcat by running this command
useradd -r -m -d /usr/local/tomcat9/ -s /sbin/nologin tomcat

I appreciate any help you can provide.
0
I need to performance tune front end application running in node js ,d3 js , html , javascript , css with express server and  with back end in war file  done in sbt deployed on tomcat using spark scala mongdb hive kafka mysql hadoop. Let me know the best tools to monitor and performance tune the app for speed , good response etc., Thank you in advance.
0
OWASP Proactive Controls
LVL 13
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Hello, how the Inheritance and Polymorphism Infography methods are created to show the following print results in Java.

Black Widow speaks: Help
Black Widow runs: slow
Hulk runs: fast
Hulk jumps: high
Hulk flies: when Hulk jumps: high
The fighter plane 2 flies: with jet engine
Black Widow runs: slow
Hulk runs: fast

Open in new window



public class Human {
    
   protected String name;
   
   public Human(String name){
       this.name = name;
   }
   
   public void corre(){
   System.out.println(name + " corre lento");
   }
   
   public void salta(){
   System.out.println(name + " salta bajo");
   }
      
   public void habla(String mensaje){
   System.out.println(name + " dice " + mensaje);
   
   }
}   


class Men extends Human {
    private Object bodyMen;
    
    public Men(String name){ 
       super(name);
    }
}

class Woman extends Human {
    private Object bodyWoman;
    
    public Woman(String name){ 
       super(name);
    }
}

class Hulk extends Men{
    
    private Object menGreen;
    
    public Hulk(String name)
    {
        super(name);
    }
    
    @Override
    public void corre(){
    System.out.println(name + " corre veloz");
    }
    
    @Override
    public void salta(){
    System.out.println(name + " salta alto");
    }
    
    public void vuela(){
    System.out.println(name + "vuela cuando");
    this.salta();
    } 
    
}

class Airplane{
        public String name;
        public Airplane(String name){
            

Open in new window

0
How to setup JNDI in apache, better method to connect DB

Please advice the steps
0
HI, I am new to wsdl2java tool. Does anyone know how to use wsdl2java.bat ?

Thanks
0
Hi, I am new to soap web service. I need build java classes from an existing wsdl file. I right click the wsdl file, ->Web Service -> Generate java bean skeleton. then I got some error:

Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -d C:\Users\workspaceTest\SQueryWebService\.cxftmp/src -classdir C:\Users\workspaceTest\SQueryWebService\build\classes -p http://netg.z.com/WS/SQueryWS/=com.z.netg.ws.squeryws -impl -validate -exsh false -dns true -dex true -wsdlLocation file:/C:/Users/workspaceTest/SQueryWebService/WebContent/wsdl/SQueryWS.wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 file:/C:/Users/workspaceTest/SQueryWebService/WebContent/wsdl/SQueryWS.wsdl
wsdl2java - Apache CXF 3.1.11


WSDLToJava Error: java.lang.NullPointerException

org.apache.cxf.tools.common.ToolException: java.lang.NullPointerException
	at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:424)
	at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
	at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
	at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
	at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:185)
Caused by: java.lang.NullPointerException
	at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding$3.resolveResource(JAXBDataBinding.java:992)
	at 

Open in new window

0
I fetch latitude and longitude from the location manager but it doesn't connect with thingboard HTTP iot cloud. I used HTTP post response. I have encoded the latitude and longitude. the problem is it shows the error java.io.IOException: closed.i trying to connect the iot thingsboard cloud and post my latitude and and longitude data
package com.example.currentgpslocation;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLEncoder;

import javax.net.ssl.HttpsURLConnection;


public class MainActivity<policy> extends AppCompatActivity implements LocationListener {

    LocationManager locationManager;

    String GPS_PROVIDER;
    String data;


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

        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria = new 

Open in new window

0
Hi Experts,

Does JAXB work under Java 5?

https://www.mkyong.com/java/jaxb-hello-world-example/

the above link example is it possible with java1.5?
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.