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: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Can we develop cross-platform applications using electron ?

if yes, need some links for reference to develop cross-platform applications
0
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
What is the issue with the above code and how would you fix it?
indentation does not matter in this code, ":=" denotes the substitution, and "=" is the equal comparator.

========
Initial state of an array "a":

[[2, NULL, 2, NULL],
 [2, NULL, 2, NULL],
 [NULL, NULL, NULL, NULL],
 [NULL, NULL, NULL, NULL]]

========
Main function:

FUNCTION foo()
    FOR y := 0 to 3
        FOR x := 0 to 3
            IF a[x+1][y] != NULL
                IF a[x+1][y] = a[x][y]
                    a[x][y] := a[x][y]*2
                    a[x+1][y] := NULL
                END IF
                IF a[x][y] = NULL
                    a[x][y] := a[x+1][y]
                    a[x+1][y] := NULL
                END IF
            END IF
        END FOR
   END FOR
END FUNCTION


What does the foo function do?

How could you make foo more generic? Can we have three possible generalization directions ?
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
Websocket or TCP or Push Notification ????

I am planning to build a mobile app to see the updates of stocks being added by the user as soon the price got updated.

1. Do we need to use Websocket or TCP or push notification in this case? Which one is better ?
2. Do we have any stock market test API's which supports Websocket or TCP or Push notification to cross check the feasibility, stability, reliability and latency ?
3. What are the differences between websocket vs TCP vs Push Notification ???

Need answers for the above three questions and the final decision as well. Please Suggest.
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
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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
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
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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
Hello Experts, I am building an installer and as part of the package, I need to install a H2 db which I want to happen silently when the user clicks Ok. Currently, the user is asked for the path of the H2 database, etc. Is there any way I can pass the defaults as parameters along with the ExecWait command?

	setOutPath $INSTDIR
	
	MessageBox MB_OK \
    "The lightweight H2 Database will be installed which is a prerequisite for the setup."
	File "Installers\h2-setup.exe"
	ExecWait '"$INSTDIR\h2-setup.exe"'	$0

Open in new window

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
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

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.