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

Hello,
Need advise on writing the  an algorithm for the spec below:
Return 3 digit integer as day month year by adding  an number to a given date
Example date given is 1-1-2019 and integer to be added is 40 . Also just need the logic without any built in functions.
Any suggestions?
Thanks
0
HTML5 and CSS3 Fundamentals
LVL 12
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

How to specify/setup root certificate with the parameter "deployment.user.security.cacerts" for jave (current version: java-1.8.0-oracle-1.8.0.xxx) on Linux (Red Hat 2.6.32-754.9.1.xxx.x86_64)?  Since the java version is often upgraded, would like to place the root certificate in an unchangeable place. Can any gurus shed some light to it? Thanks a lot.
0
how to understand big new project code quickly and effectively to write new enhancement to existing code or to fix some defects or to debug to improve some areas of poor performance.

what are the tips and recommendations , best practices around this
Please advise
0
what is difference between below two eclipse short cuts

control +alt+h
(above does not yield any results saying members calling that method in workspace it shows at bottom again same method nothing else)

control +shift+g
(above shows like 8 references in workspace)

please advise
shortcut.png
0
I have 40 servers that have java installed.  My network guy keyed in on the fact that support for java is ending sometime soon.  I have no idea if these servers actually use java that have it installed.  Is there a way to tell if a server is actually using java or if an app or service installed on that server is using java.
Thank you

the servers will be a mix of the following versions
2008
2012
2016
0
//1.get the staff info from the GUI
        String firstname = firstnameTextField.getText();
        String lastname = surnameTextField.getText();
        String email = emailTextField.getText();
        String pwd = pwdTextField.getText();
        String access = accessTextField.getText();
       
       
        //check fields are not empty
        if (firstname.equals("")) {
            JOptionPane.showMessageDialog(null, "Add A Username");
        } else if (lastname.equals("")) {
            JOptionPane.showMessageDialog(null, "Add A Password");
        } else if (email.equals("")) {
            JOptionPane.showMessageDialog(null, "Enter  Email");
        } else if ((pwd.equals(""))) {
            JOptionPane.showMessageDialog(null, "Enter  password");
        } else {

            //2.Save to the database
            Staff s = new Staff(firstname, lastname, email, pwd, access);

            try {
                //using the method add new staff, this works for the search
                accessObjectMethods.addNewStaff(s);
             
                jPanel1.add(jButton1); //use the button
                JOptionPane.showMessageDialog(null, "The account had been created");

                this.dispose();
                new MainMenu().setVisible(true);//reopens the log in page
            } catch (SQLException ex) {
                Logger.getLogger(RegisterStaff1.class.getName()).log(Level.SEVERE, null, ex);
            }
        }…
0
I need to test the below Java main class with JUnit and Mockito/EasyMock without using PowerMockito so that I get the Code Coverage in Jacoco. I want to have the output as "Mocked Result" without getting the actual output as "Actual Result" when I call the MainClass.process() method in the Test Class.

public class MainClass {
   
    public String process() {
          AnotherClass another = new AnotherClass();
     String result = another.getResult();
          return result;
    }
}
-----------------------------------------------------------------------------
public class AnotherClass {
      public String getResult() {
            return "Actual Result";
      }
}
----------------------------------------------------------------------------
0
How do I move a JSONArray or JSONObject positionally within a jSONArray?

I started with the example in the link below, but that sorts and I just want to move an object or array to the first position or any arbitrary position.

I don't want to sort as shown in the example in the URL, but I just want to move a specific object to the top or first position.

https://stackoverflow.com/questions/4277715/how-to-sort-json-object-in-java
0
Hello there,

I want to restart my java application which is running on Ubuntu 16.04 as service. But the problem I have is on Ubuntu when I want to restart my java application service, I do as follows
sudo service myapp restart

Open in new window

and then Ubuntu asks for password. Now how can I tell Ubuntu to not ask password when I send this cmd from my application.

//Restart application server
		router.get("/restartAppService").handler(ctx -> {
			/* Build command: sudo service AooService stop */
			  final ArrayList<String> command = new ArrayList<String>();
			  command.add("sudo service TutisService restart");
			  System.out.println("CMD ----"+command.toString());
			  final ProcessBuilder builder = new ProcessBuilder(command);
			  	try {
			  		builder.start();
				} catch (IOException e) {
					System.out.println("EXCEPTION WHILE RESTARTING SERVICE----"+e.getMessage());
					e.printStackTrace();
				}
			  //System.exit(0);
		});

Open in new window


Any help will be appreciated!!

cheers
Zolf
0
I have a dynamic web project ( SOAP web service), which takes parameters from a received message and inserts data to oracle db. This all works fine. However, db connection url, password and user are hardcoded.

This web app will be distributed to a number of servers with different db connection details, so it can't be hardcoded and generating a new app for each server is not an option.

I wonder if I could store needed info in an xml file and read from there. Is someone able to give me a nice simple example of how to do it?

Also, where such file would have to be placed, bearing in mind it would have to be possible to edit it after the deployment?
0
Rowby Goren Makes an Impact on Screen and Online
LVL 12
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Please guide me to solve this problem. I'm setting up Zimbra Collaboration Open Source as service provider (SP) and simplesamlphp as Identity Provider (IdP). I have installed samlextn.jar in /opt/zimbra/lib/ext/saml/ and configured SAML authentication for Zimbra server.

Zimbra server environment:

[zimbra@devzimbra ~]$ zmcontrol -v
Release 7.2.0_GA_2669.RHEL6_64_20120410002025 CentOS6_64 FOSS edition.
[zimbra@devzimbra ~]$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

The problem is after successfully authenticate in IdP and redirected to http://devzimbra/service/extension/samlreceiver, I'm getting this error in browser:

HTTP ERROR 500
Problem accessing /service/extension/samlreceiver. Reason:

    Unparseable date: "2018-12-13T09:48:09Z"



In /opt/zimbra/log/mailbox.log:
---------------------------
2018-12-14 10:51:31,149 INFO  [btpool0-13://devzimbra/service/extension/samlreceiver] [] extensions - Error in validating SAML response
java.text.ParseException: Unparseable date: "2018-12-14T02:51:14Z"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at com.zimbra.cs.security.saml.SamlResponseHandler.validateSamlAssertion(SamlResponseHandler.java:231)
    at com.zimbra.cs.security.saml.SamlResponseHandler.validateSamlResponse(SamlResponseHandler.java:186)
    at …
0
A high school student needs help learning Java.  I first looked at books by PeachPit Press, but they are all 16+ years old.

Can somebody recommend a great visual guide for a beginner, or some links?

I am going to try and help.  I've been programming for a  L  O  N  G  time.  My latest was PHP.  I figure I could learn along with the student - at least i have the coding mentality.


Thanks.
0
Hi Team,

This is a very simple question related t strings in JAVA .  I know String Objects are immutable and JVM maintains  a copy of the string literal in String constant pool.

But my question is with respect to this context..

String str =" Hello"   ;    --> It is stored in SCP
String str1 = str + "Wellome to Strings"  ;


When  I issue this statement , does the java compiler stores the string Welcome to Srings in SCP and at the runtime , create a String Object  in heap after concatenating Wellcome to Strings with value stored in the variable str and make a copy of this string in SCP.
0
0
Java Control Panel not showing up in Windows 10 64 bit.

Was looking for a solution within Windows 10, or is the solution downloading Java.

The latest version of Java is loaded as indicated by its appearance in Programs and features.

Java 8 something somethning....
0
lets say i have method called
 testSum(){
c=a+b;
}

i clicked on testSum
i did CONTROL+ALT+H i see call hierarchy results
if I clicked testSum did CONTROL+H  then i get search option with my method and its class, package selected automatically and i click SEARCH without changing anything(it says java search)

how above call hierarchy different from java search is different from previous one?

please advise
0
we have hundreds of flows like registration, sales, cancellation from front end java applicatio to SQL database.

Microsoft SQL database has hundreds of stored procedures, tables, columns, joins, primary keys, foreign keys etc.

it is getting hard to check database stored procedures, tables if issue come on say sales flow to check quickly as no proper documention on database side.

what kind of documentation is good to have on database side.

i think like one excel spreadsheet  with columns like stored procedures, then next column relevant tables then next column table 1 columns, table 2 columns and then highight primary key as yellow color and then next column joins and other related tables

please advise any other better ways and best practices and links resources on it
0
What are the common patterns for distributed software architecture? Is there any list?
0
I need to give a quiz to all candidates when hiring to assess their breath and depth of knowledge. An example is Requirements Engineering position, or another example Solutions Architect, or the last example Software Engineer (Backend) and Software Engineer (Frontend).

I need to design the quiz content myself, which is not an issue, but the issue is the quiz software. It should be either Java or PHP, and it should be very comfortable and easy to edit quiz content with it, but also it must be possible to allow candidates to take the quiz only once. They must not be allowed to cancel it when it is being taken. They must not spend too much time submitting it (for example 5 minutes limit for the whole quiz), and every applicant must be able to only see the quiz when I create his ID or account and invite him to complete it.

Do you know any existing quiz software that will do this, and it's Open Source or a free service for employers? I want to see their results, but I don't want them to see their results themselves. Quizzes are fairly common, hence building a new custom software is excluded. It must be reused.
0
Python 3 Fundamentals
LVL 12
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

In Java, I have a requirement to allow user-defined properties.

Example:
Database table: property

Table Row:
ID: 1
Label: Annual Salary

Database table: contact
ID: 1
Email: test@example.com
...

In addition to existing columns for contacts, users will define their own columns in Property Manager. Such column is "Annual Revenue" (number) for example.

So we need a table:
Database table: contact_properties
ID: 1
Contact_id: 1
Property_id 1

In this table we link user-defined properties to contacts

We however need more. We have 4 fixed (immutable) field types: Text, Number, Checkbox, Dropdown.
Every user-defined property should have a type, something like in MS Excel, but easier.

And finally, every user-defined property should belong to some group. Groups are user-defined too.

Database table: property_group

Row:
ID: 1
Label: Contact Information

ID: 2
Label: Company information

...

How should we annotate entities in Java to persist the above? Attached is all source code (mini project). See the entity package in module-properties. I have also prepared something quickly in the App.java (main) to test persistence.

The current exceptoin is:
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: uk.co.mybigdata.crm.module.properties.entity.Property.optionList, could not initialize proxy - no Session
      at …
0
I need to convert a 'Long Date' to HL7 date, and I was trying to do it with some of functions available and not appending each component of the date and time independently.
Input format: 'Mon May 21, 2018 11:52 PM'
Output format: 'yyyyMMddhhmmss'

      // example: Mon May 21, 2018 11:52 PM
      var d1 = new Date("Mon May 21, 2018 11:52 PM");    
      // var d = org.joda.time.format.DateTimeFormat.forPattern('MM/dd/yyyy').parseDateTime(ServDatetime);

      var dt = d1.toLocaleDateString() + " " + d1.toLocaleTimeString().replace(" CDT", "").replace(" PM", "");
      
      var d2 = org.joda.time.format.DateTimeFormat.forPattern('DDD MMM dd, yyyy hh:mm').parseDateTime(dt);    // This line fails !!, not sure how to set this up ??
      
      alert('New Date: ' + d2.toString());
0
How to set the default font size in Java application ? The size shown in JOption frame is small.

Thx
0
I need to create a small game.   I want to create 3 JOPtionPane for 3 users. Each user will ask some questions on each JOptionPane and the result will be instantly updated on the JOptionPane (ie. the message on the pane will be changed dynamically based on user input). Any example to show how it works ?

Thx
0
Hi
I have Oracle SQL Dev version v17.4 with Java Platform 1.8.

I would like to connect to an Ms Access table but i can't see the tab. How can I add it?
Oracle Missing Ms Access tab
In an older Oracle SQL Dev, (1.5), i do have that tab.
0
Dear  sirs,
Please help with the following.
I would like to know how to access extra parameters (besides username and password), when dealing with Spring Security Login form.
Please, assist.
A sample of code will be helpful.

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