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

Looking for link where all java related working applications are available or displayed or listed.

github has many projects however hard to find the working applications as many are sample ones and not updated to uptodate and no support if the project doesn't work.

example, https://en.wikipedia.org/wiki/Category:Software_programmed_in_Java_(programming_language)
0
Cloud Class® Course: CompTIA Healthcare IT Tech
LVL 12
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

java().getName()

java().getId()
i saw above kind of lines of code in junits

what is java() means

is it new in java 8 which i never heard of?

please advise
0
what are differences between eclipse short cuts F3 and Control +Shift+G
when to use which one?

Please advise
0
Hi,

I'm working on a java project where the build is done using maven. The final war/jar size seems to be very big.

When the war/jar size will be increased? I am not sure how to reduce the size of the jar.

How to build only the jars required for the project?

Currently we just given maven build plugin in the dependencies and artifact id on the top which builds the war or jar

Please advise.

Thanks.
0
Hello Experts,
Just wondering if there is a any opensource JAVA JAR file that I can use for a project that allows me to connect to a DB (like mysql or H2), create tables, insert data into tables, etc. Basically, I am looking for a solution which builds the queries itself when data is passed as parameters to a method. Any inputs really appreciated.
0
We only increment by 1 the matrix table when we encounter 1 only if the entire proceeding row has zero and the entire succeeding row has zero. If there is something like this 0,1,1,1,1,0 then we increment only 1 not four times. zero represents none in the matrix table so for instance if the entire succeeding row is and the current row is 1  then in matrix table we want to increment the index where the row is none and column is column1.  I have written some code but it only happens to increment for one column.

I have attached a file with data.
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Incrementing {

    static String[][] resultMatrix = new String[30][30];

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int n = 0;
        //in_data1 is used to read a line from the file
        String in_data1;
        //in_data2 is used to read a line from the file after in_data1 line
        String in_data2 = "";
        //in_data1_arr array is used to store the data from in_data1 split by ","
        String[] in_data1_arr;
        //in_data2_arr array is used to store the data from in_data2 split by ","
        String[] in_data2_arr;
        //this is the array which has 34 indices in which we increment the the index which satisfy the condition
        int[] count = new int[34];

        // display output matrix …
0
I am tring to decrypt a excel file but there is an error occur Input length must be multiple of 8 when decrypting with padded cipher

private String decrypt1(InputStream encrypteddata) throws IOException, IllegalBlockSizeException, BadPaddingException {
        try {
            byte k[] = "NiTh5252".getBytes();
            System.out.println("Encrypted Data stored in byte k: " + Arrays.toString("NiTh5252".getBytes()));
            byte[] bytes = IOUtils.toByteArray(encrypteddata);
            System.out.println("Encrypted Data stored in bytes: " + Arrays.toString(bytes));
            SecretKeySpec key = new SecretKeySpec(k, "DES");
            Cipher enc = Cipher.getInstance("DES");
            enc.init(Cipher.DECRYPT_MODE, key);
            byte[] textDecrypted = enc.doFinal(bytes);               ///error in this line
            System.out.println("Encrypted Data stored in textDecrypted: " + Arrays.toString(textDecrypted));
            System.out.append("Decrypted Text is :" + new String(textDecrypted));
            return new String(textDecrypted);
        } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
            e.printStackTrace();
        }
        return null;
    }

Open in new window

0
Hi,
I have deployed my code on two machines M1 and M2.
They fetch a USer Object which contains details about name, designation, emailID etc corresponding to a userId.
Currently i am storing them in cache like this :

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
    private Cache<String, User> userCache;
 userCache = CacheBuilder.newBuilder()
                .maximumSize(1000)
                .expireAfterWrite(60, TimeUnit.MINUTES).build();

Open in new window


But i just realized that there will be two caches on M1 and M2 separately. That could be an issue because say M1 caches data for a user. But the load balancer than sends the request to M2 and it will have to again fetch data.
what are the possible solutions to this ?
I can think of keeping another machine with all the cache data in RAM.
And so create a cache on M1 and M2 that programmatically connects to this machine.
But then comes the problem of having one more replica of this machine because in case one is down then
we still have data access...
Please suggest what is used to solve this type of problem ?

Thanks
0
The table name will be dynamic and need to return the list of objects dynamically. The parameters also dynamic however 4 parameters will be same for any table.

Method name accepts the table name and 4 parameters required to query any table

List<?> conversations = jdbcTemplate.queryForList(
         "select * from "+ tableName + " where id=? and userName=? and
 password=? and tenantId=?" , paramsObjectArray);

tableName is a string which comes dynamically paramsObjectArray is a Object[] which comes dynamically. paramsObjectArray is of string values

ex: Object[] obj = new Object[4]; obj[0]="one"; etc.,

I'm using queryForList method with parameters to avoid SQL injection directly.

Currently the query throws invalid column type.

Thanks.
0
We are working on an e-commerce application. We are at the point of integrating Elasticsearch for the product search engine with Spring boot application with Spring data. We have tried different tutorials online (check links below) but they all doesn't run well. No indexes are added to the Elasticsearch.  We are using ES 6.3.1 and the maven dependency is as follows.

               
 <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
		</dependency>

Open in new window


Product Entity

@Entity
@Document(indexName = "product", type="default")
public class Product {

    @javax.persistence.Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long Id;
    private String Name;
    @Lob
    @Type(type = "text")
    private String Description;
    private String ShortDescript;
    private String Model;
    private String Brand;
    private String Sku;
    private String Isbn;
    private Integer Shipping;
    private BigDecimal SalePrice;
    private BigDecimal RegularPrice;
    private Integer Quantity;
    private Double Weight;

//other code here
}

Open in new window


Product Repository

@Repository
public interface ProductRepository extends ElasticsearchCrudRepository<Product, Long> {

    @Query("select p from Product p where p.supplier.id = ?1")
    public Iterable<Product> GetAllProductsBySupplier(Long id);
   
}

Open in new window


We have installed kibana locally and have tested with test data and it works. But not with the Spring Boot application. Need your help. Thanks

1. https://www.baeldung.com/spring-data-elasticsearch-tutorial
2.https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/
0
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Getting "Type safety: Unchecked cast from Object to Map<String, String>" warning during the typecasting.

Could you guide me how I can resolve it?.  Please check below-mentioned code:-

Map<String, String> columns = ((Map<String, String>) map.get("columns"));
0
Dear sirs,
Please help, how can I avoid this exception. It happens when my http response includes an empty List in the body.

org.springframework.web.client.RestClientException: Error while extracting response for type [java.util.List<?>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 1] at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:115) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:991) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:974) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:725) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:698) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:649) at com.finger.services.AppRestTemplateService.doHandleListRequest(AppRestTemplateService.java:140) at

Please, assist
0
I use the RXTX to read the input from a scale device, the code is the following:

                    // configuro el puerto
                    serialPort = (SerialPort) portIdentifier.open("ListPortClass", 1200);

                    int b = serialPort.getBaudRate();
                    serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

                    InputStream mInputFromPort = serialPort.getInputStream();

                    // antes de empesar a leer le doy un tiempo apra que se llene el buffer
                    this.sleep(300);

                    // leo el peso
                    while(true){
                                        byte mBytesIn[] = new byte[2048];
                                        mInputFromPort.read(mBytesIn);

                                        String value = new String(mBytesIn);
                    }

                    // en caso de error cierro el puerto
                    serialPort.close();

Open in new window


the data format is: "000" + "000025" + "000000" + "\r\n" + ETX;

the problem i have is the string read from com port is not stable, sometimes is like "000025" + "000000" + "\r\n" + ETX;
And something is: "000000" + "\r\n" + ETX + "000" + "000025" + "000000" + "\r\n" + ETX;

how i can validate the input to avoid the misformat data and only read the correct format
0
I have the following code that calls a class "m", passing in a List (and a double) as follows...

my_outlier = (double) m.getOutlier(Arrays.asList(1.1, 2.1, 31.1, 4, 3, 4), 0.95)

Open in new window


Notice that the List is hard-coded.  I need to pass in a List variable somehow, but I can't get it to work. The "asList" seems to need that hard-coded list of numbers within parenthesis. Any suggestions?
0
I'm trying to configure LDAP authentication in my application, i'm using sprintg boot for Dev.
Here i want the end-to-end LDAP configuration includeing the User and Admin roles.

How do i do the LDAP authentocaion to maintain the roles in my application?

Thanks in Advance!
0
MY JMX console is down. Observed jboss services are in hung state. So, When i am trying to restart my jboss in my putty its not getting restarted and showing the below info in the log continuously......I have tried to reboot the server once - its worked. but the next day its the same issue.

 INFO  [JMSContainerInvoker] Waiting for reconnect internal 10000ms for OntarioStatusListenerBean
INFO  [JMSContainerInvoker] Trying to reconnect to JMS provider for OntarioStatusListenerBean
ERROR [JMSContainerInvoker] Reconnect failed: JMS provider failure detected for OntarioStatusListenerBean

Again.........starts


INFO  [JMSContainerInvoker] Waiting for reconnect internal 10000ms for OntarioStatusListenerBean


Please help me with fix for this issue.
0
I am reading a bunch of csv files that share the same structure and I would like to skip the first three columns.
This is my code:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Readcsv {
    public static void main(String args[]) throws FileNotFoundException {
        int n = 0;
        int[] count = new int[25];
        String fileRead;
        File file = new File("folder path");
        File[] fileNames = file.listFiles();
        assert fileNames != null;
        for (File fileNamed: fileNames) {
            Scanner inputFile = new Scanner(new FileReader(fileNamed+""));

            while (inputFile.hasNext()) {
                fileRead = inputFile.nextLine();
                for (String filed : fileRead.split(",")) {
                    if (filed.equals("1")) {
                        count[n] = count[n] + 1;
                    }
                    n++;
                }
                n = 0;
            }
        }
        for (int c_out:count) {
            System.out.print(c_out+" , ");
        }
    }
}
0
Unable to send an emailjavax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
      javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
0
Dynamic Form/Table from BackEnd for every entities which has CRUD operations

I'm developing a Java Web application.

I need to

1st option list the user clicked entity menu on the UI
2nd search page where user enter values for the fields and we need to publish the search results in a table

Note: the number of columns will differ from entity to entity

In either case, i need to know hoe to define a generic entity, pojo, DAO and DAOimpl, service and controller class and view jsp page

What should be the return type Object for #1, #2

How to create a generic jsp page to display the results for any entity

Please advise

Thanks
0
Cloud Class® Course: MCSA MCSE Windows Server 2012
LVL 12
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

flames.txtplease rectify the below issue in java programs flames.
Flames is a program that take two string  after getting input of two string it can remove the common charter in both the String:after it can find the length of two string  and based on the length it give Some clue:that u are suggested
0
Generic Form, Controller, Service and Search fields for Java Web Application

I want to built an application where there will be 500 screens which needs basic CRUD operation and individual field search or combined search field option is required.

Everything when we build entity in Java/JPA we want to have separate controller, service, repository and search api.

Is any framework or open source it has all in common, where we can use the generic controller, service, repository and search and export options by default instead of writing any new code snippet

However we can extend whenever is required.

Please advise.
0
Online Docker creation like Online-Compilers

Below are the online compilers for several programming languages...

Do we have a similar kind of online utility to create DOCKER files with the given files or project. Setting and Installation seems difficult.

Run DART Program Online
--------------------------------------
https://dartpad.dartlang.org/

https://www.jdoodle.com/execute-dart-online

https://www.tutorialspoint.com/execute_dart_online.php

http://flutterhelp.com/dart-compiler/

Zero Installation to Learn/Run ANY program
---------------------------------------------------------------
https://www.tutorialspoint.com/codingground.htm

http://code.runnable.com/

https://www.codechef.com/ide

https://ideone.com/

http://codepad.org/

https://codepad.remoteinterview.io/

https://www.jdoodle.com/

http://www.onlinecompiler.net/

http://code.geeksforgeeks.org/

https://www.codiva.io/
0
I want to write a java program that loop through files in the directory and keep track of the changes from one micro pattern to another. The files contain names of hundreds of classes, in the file 0 means the class doesn’t matches a micro pattern and 1 matches that specific micro pattern. So, I want to update the matrix file every time micro pattern is changing.

For example:
Version 1 – class A record, class B function pointer, class C cobol like
Version 2 – class  A function pointer, class  B cobol like, class  C recursive
Version 3 – class  A cobol like, class B recursive, class C function Pointer
 
Class A is changing from record (V1) to function pointer (V2) to cobol like (V3). Therefore there is a 1 from record to function pointer, and a 1 from function pointer from cobol like:
Matrix table
                                           Record                  Function Pointer               Cobol like                    Recursive
Record                                                            1              
Function pointer                    1       
Cobol like                            
recursive                            

Now for class B is a function pointer in V1, then a cobol like in V2, then a recursive in V3.
                                          Record          Function Pointer          Cobol like           Recursive
Record                                                         1              
Function pointer                                                                               2       
Cobol like                                                                                                         …
0
I am having a java application with source code and libraries.

I would like to convert the entire java source to DART. Basically wants to convert the java application to DART Application (Java flavour) - https://www.dartlang.org/

Can someone help me what would be the easiest way or best approach or ways to quickly convert a java project to DART project ???

All the functionalities are same and no change in the functionality of the appplication.
0
Hi Expert,

I'm getting below Oracle Web-logic application error could anybody please guide me how to fix it!

subsystem is initializing on Server WebWORKS6.>
####<Aug 2, 2018 1:09:38 PM GMT> <Info> <Store> <trpridrps1app6> <WebWORKS6> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1533215378092> <BEA-280008> <Opening the persistent file store "WLS_DIAGNOSTICS" for recovery: directory=D:\Manu\IDRPPSA\srvr6\config\JDADomain\servers\WebWORKS6\data\store\diagnostics requestedWritePolicy="Disabled" fileLockingEnabled=true driver="wlfileio3".>
####<Aug 2, 2018 1:09:38 PM GMT> <Critical> <WebLogicServer> <trpridrps1app6> <WebWORKS6> <Main Thread> <<WLS Kernel>> <> <> <1533215378108> <BEA-000386> <Server subsystem failed. Reason: java.lang.NullPointerException
java.lang.NullPointerException
       at weblogic.store.io.file.StoreFile.close(StoreFile.java:440)
       at weblogic.store.io.file.Heap.open(Heap.java:320)
       at weblogic.store.io.file.FileStoreIO.open(FileStoreIO.java:104)
       at weblogic.store.internal.PersistentStoreImpl.recoverStoreConnections(PersistentStoreImpl.java:431)
       at weblogic.store.internal.PersistentStoreImpl.open(PersistentStoreImpl.java:422)
       at weblogic.store.xa.PersistentStoreManagerXA.createFileStore(PersistentStoreManagerXA.java:117)
       at weblogic.diagnostics.archive.DiagnosticStoreRepository.getStore(DiagnosticStoreRepository.java:91)
       at …
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.