Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

Java

99K

Solutions

32K

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

We are trying to run a .jar file from a network location and we keep getting the error "Error: Unable to access jarfile".  We have tried linux and window shares so it is not a rights issue. We can not copy it over to run it because all the files with it are huge. Here is the command we are trying. I understand that the .jar file is trying to run on the network drive is there a way around this? Thanks!

 java -Xmx768m -jar "\\fs1\groups\bios\program1.jar" -b \\192.168.15.20\Transfer\run.xml

Open in new window


-Windows Pro 10 x64
0
[Webinar] Database Backup and Recovery
LVL 11
[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Hi

I have my pygame ready and I'm going to start being a coding-personal-trainer teacher for nearby kids.
No doubt, there are many books for me to gain wisdom on how to proceed? Or, is there a good web-site done?
I asked some previous questions in this sphere, but some additional references/syllabus would be useful.
Thanks
0
Please see below some java code which I am trying to compile and run. I am fully aware that the code has an error. I also know how to fix it (as you can see from the comment I added just below: while (true){). What I don't however know is what this code is actually doing. Is it looping infinitely? Does it stop abruptly? What is the exact reason behind why I get a compile error (Unable to execute program; could not compile!)?

I am thinking, if the while condition is not met because it is false, should the code not ignore the while block and jump to the next line of code outside the while block - 'System.out.println("out of loop");' - and run it once and then stop?

import java.util.Random;

public class PartA {

        //loop until i is equal to j
		private static void loop6(){
			Random r = new Random();
			int i = 0;
			int j = 10;
			while (false){
          	        //while (true){
				i = r.nextInt(10);
				j = r.nextInt(1000);
				System.out.println("i = "+i+" and j = "+j);
				if (i==j)break;
			}
			System.out.println("out of loop");
		}

        private static void runLoops() {
		loop6();
		System.out.println();
	}


	public static void main(String[] args) {
		runLoops();
	}

}

Open in new window


thanks in advance
0
I have this java class:

import java.util.Random;
import java.util.Scanner;

public class CustomerVerifier {
    private static int[] pins = new int[]{1234, 1111, 4321, 5555, 7777, 1010, 9876};
    private static String[] customers = new String[]{"Bob", "Rob", "Tim", "Jim", "Sam", "Jon", "Tom"};
    private static String[] memorableWords= new String[]{"fishing", "Mittens", "Arsenal", "6packYeah", "Porsche911", "puppies", "CSI4Ever"};
    private static Scanner scanner = new Scanner(System.in);


    private static boolean askUserToContinue() {
        String input = getUserInput("Verify another customer? ");
        return input.trim().toLowerCase().startsWith("y"); //see the String API for documentation of the trim() method
    }

    private static String getCustomerFromUser() {
        return getUserInput("Enter customer name: ");
    }

    private static int getPinFromUser() {
        String input = getUserInput("Enter PIN: ");
        return Integer.parseInt(input);  //see the subject guide volume 1 section 9.6 for more on the parseInt(String) method
    }

    private static String getUserInput(String msg) {
        System.out.print(msg);
        return scanner.nextLine();
    }

    private static boolean isValidPin(String customer, int pin) {
        int customerIndex = -1;
        for (int i = 0; i < customers.length; i++) {
            if (customer.equals((customers[i]))) {  //see the String API for documentation of the equals(Object) method
               

Open in new window

0
I have this java class:

import java.util.Random;
import java.util.Scanner;

public class CustomerVerifier {
    private static int[] pins = new int[]{1234, 1111, 4321, 5555, 7777, 1010, 9876};
    private static String[] customers = new String[]{"Bob", "Rob", "Tim", "Jim", "Sam", "Jon", "Tom"};
    private static String[] memorableWords= new String[]{"fishing", "Mittens", "Arsenal", "6packYeah", "Porsche911", "puppies", "CSI4Ever"};
    private static Scanner scanner = new Scanner(System.in);


    private static boolean askUserToContinue() {
        String input = getUserInput("Verify another customer? ");
        return input.trim().toLowerCase().startsWith("y"); //see the String API for documentation of the trim() method
    }

    private static String getCustomerFromUser() {
        return getUserInput("Enter customer name: ");
    }

    private static int getPinFromUser() {
        String input = getUserInput("Enter PIN: ");
        return Integer.parseInt(input);  //see the subject guide volume 1 section 9.6 for more on the parseInt(String) method
    }

    private static String getUserInput(String msg) {
        System.out.print(msg);
        return scanner.nextLine();
    }

    private static boolean isValidPin(String customer, int pin) {
        int customerIndex = -1;
        for (int i = 0; i < customers.length; i++) {
            if (customer.equals((customers[i]))) {  //see the String API for documentation of the equals(Object) method
               

Open in new window

0
Please see below some java code which I am trying to compile and run. I am fully aware that the code has an error. I also know how to fix it (as you can see from the comment just below). What I don't however know is what this code is actually doing.
Is it looping infinitely? Does it stop abruptly? What is the exact reason behind why I get a compile error (unreachable statement in line 13)?

import java.util.Random;

public class PartA {

	//loop 5 times
	private static void loop4() {
		int i = 5;
	        while(5 < 10) {
		//while(i < 10) {
	        	System.out.println("In loop i = "+i);
	            	i++;
	        }
	        System.out.println("Out of loop");
	}

        private static void runLoops() {
		loop4();
		System.out.println();
	}


	public static void main(String[] args) {
		runLoops();
	}

}

Open in new window


thanks in advance
0
Please see below some java code which I am trying to compile and run. I am fully aware that the code has an error. I also know how to fix it (as you can see from the comment just below). What I don't however know is what this code is actually doing.
Is it looping infinitely? Does it stop abruptly? What is the exact reason behind why I get a compile error (interrupted because taking more than 5 secs to run)?

import java.util.Random;

public class PartA {

	//loop 10 times
	private static void loop3() {
		int i = 0;
		do {
			System.out.println("In loop "+i);
              		//i++;
			} while(i < 10);
			System.out.println("Out of loop");
		}

        private static void runLoops() {
		loop3();
		System.out.println();
	}


	public static void main(String[] args) {
		runLoops();
	}

}

Open in new window


thanks in advance
0
Please see below some java code which I am trying to compile and run. I am fully aware that the code has an error. I also know how to fix it (as you can see from the comment just below). What I don't however know is what this code is actually doing.
Is it looping infinitely? Does it stop abruptly? What is the exact reason behind why I get a compile error?

import java.util.Random;

public class PartA {

    //loop 10 times
    private static void loop2() {
        for(;;) System.out.println("In loop");
        //for(int i = 0; i < 10; i++) System.out.println("In loop");
        System.out.println("Out of loop");
    }

        private static void runLoops() {
		loop2();
		System.out.println();
	}


	public static void main(String[] args) {
		runLoops();
	}

}

Open in new window


thanks in advance
0
I am using portecle to generate a java store cert for JIRA. I created the keystore, create the key pair, generated the CSR, processed the CSR using third party CA. I then imported the root cert into Portecle. When I import the CA response I get "could not establish trust for the CA reply. The import cannot proceed.
Why is this happening as everything appears correct.
0
Hi
I'm deploying sonicwall cert from a firewall to all my windows clients.
The certificate has been distributed by GPO.
I'm having a problem with java apps (idrack) which can't connect.
I've imported this to my java store but the same issue appeared.
Eventually I will need to distribute this to all my Win and Mac clients.
0
Free Tool: Port Scanner
LVL 11
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Recursion

Given a string and a non-empty substring sub, compute recursively the largest substring which starts and ends with sub and return its length.

strDist("catcowcat", "cat") → 9
strDist("catcowcat", "cow") → 3
strDist("cccatcowcatxx", "cat") → 9
0
Hi,

How to write regex expression for below string to get the final output as

"d1a2227e-291f-4d82-8991-b9458b4ad0d3","fb48e632-3c85-483b-86b3-76f7a1c7eb25","93fa5301-29e2-4ef6-9353-686868686888"



input string= @Check:"workspace://SpacesStore/d1a2227e-291f-4d82-8991-b9458b4ad0d3" OR @Check:"workspace://SpacesStore/fb48e632-3c85-483b-86b3-76f7a1c7eb25" OR @Check:"workspace://SpacesStore/93fa5301-29e2-4ef6-9353-686868686888
0
I know that Java's array's length property is defined as public final. My question is, how does the array set a value to that 'length' property if it's final?

For example, if I do:

int arr = new arr[5];

At this point, how does array assign the number 5 to its length property internally if the 'length' property is final?
0
Given an array of ints, compute recursively if the array contains a 6. We'll use the convention of considering only the part of the array that begins at the given index. In this way, a recursive call can pass index+1 to move down the array. The initial call will pass in index as 0.

array6([1, 6, 4], 0) → true
array6([1, 4], 0) → false
array6([6], 0) → true
0
I have to add an attribute to XML node with more than 10k records so whats the best way to transform XML document faster.

I have tried StAX parser which almost takes 4 min for adding an attribute and using SAX parser it should take 5 min.

Is there any other lib available to do it better or another way to do that please give your suggestions.

Sample Code :(Using STAX Parser)
XMLStreamReader r = factory.createXMLStreamReader(new FileInputStream(inputfile));

/*Start Writing document */

XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();

XMLEventWriter xmlEventWriter = xmlOutputFactory.createXMLEventWriter(new FileOutputStream(outputfile), "UTF-8");

/*End Writing document */

int event = r.getEventType();

long startTime = System.currentTimeMillis();

        System.out.println("Started reading node from xml document....."+TimeUnit.MILLISECONDS.toSeconds(startTime));

int node1Cnt = 0,node2Cnt = 0,node3Cnt=0,node4Cnt = 0;

      while (true) {

      XMLEventFactory eventFactory = XMLEventFactory.newInstance();

            switch (event) {

            case XMLStreamConstants.START_DOCUMENT:

                 // System.out.println("Start Document.");

                  StartDocument startDocument = eventFactory.createStartDocument();

                  xmlEventWriter.add(startDocument);

                  break;

            case XMLStreamConstants.START_ELEMENT:

                              

                //Create Start node

          

Open in new window

0
I program in C# but need to write a Java app that can be downloaded and run on many platforms. The application will "scrub" confidential information from a merchant's credit card report (PDF).

It will remove the merchant's name, address, merchant ID (xxxx-xxxx-xxxx-xxxx) account number, etc.

It will do this by scanning the entire PDF and exporting non-confidential data to a CSV file.

I need this to be easy for non-techies to download and run.

What basic considerations should I have about what I should and should not consider before I start planning the design?

What frameworks help? Hurt?

What kind of installation program/script is needed?

I would host this download from my website...

Thanks.
0
Hi,
I have to remove the first character which is | from the text file,i tried with startswith it is not working,
If i use  comma as instead of pipe whole code works fine,only in case of pipe it is not working.
Please let me know how to solve it.

fileObj = new File(filePath);
            inputFS = new FileInputStream(fileObj);
            br = new BufferedReader(new InputStreamReader(inputFS));
            // read the first line
            String firstLine = br.readLine();
            // check if first character is pipe always return false even if the file has pipe as first character
            boolean isFirstCharPipe = firstLine.startsWith(Pattern.quote("|"));

Open in new window


Sample Text File
|Name|Age|Gender|Address|
0
Hi,
I have the following code :
if (task.getCompletor() != null) {
                task1.setCompletorGuid(task.getCompletor().getUserGuid());
            }

The getCompletor returns a User -  :
public WorkflowUser getCompletor() {
        return completor;
    }

what are the ways i could avoid the null check.
One way i can think of to user a NullWorkflowUser class so instead of directly returning the completor from the getter i return this object in case its null this way i dont have to have a null check and i could write the definitions which will be null for the methods inside it.
I have read about Optionals but never used it.
Can that be used here.
Which is a better approach the NullWorkflowUser or the Optional one.

And any other alternatives in java.
Thanks
0
Hi,
java.sql.Timestamp timeStamp;
Currently i am doing timeStamp.toString().split(" ")[0] to extract the date part of the timestamp.
Is there any alternate way. Its surprising that Timestamp itself does not provide any such method.

Thanks
0
Free Tool: Site Down Detector
LVL 11
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4. Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12).


count8(8) → 1
count8(818) → 2
count8(8818) → 4
0
I have a contactList = new ArrayList<>(); where I store information in this format: "name", value_for_name.

I populate my contactList inside this function:

protected Void doInBackground(Void... arg0) {
            HttpHandler sh = new HttpHandler();

            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(url);



            Log.e(TAG, "Response from url: " + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);

                    // Getting JSON Array node
                    JSONArray contacts = jsonObj.getJSONArray("results");

                    // looping through All Results
                    for (int i = 0; i < contacts.length(); i++) {
                        JSONObject c = contacts.getJSONObject(i);

                        String icon = c.getString("icon");
                        String id = c.getString("id");
                        String name = c.getString("name");



                        // tmp hash map for single contact
                        HashMap<String, String> contact = new HashMap<>();

                        // adding each child node to HashMap key => value
                        // contact.put("id", id);
                        contact.put("name", name);
                        // contact.put("email", icon);


                        // adding contact to contact list
                        

Open in new window

0
i am trying to write and store a string  in text file using buffered writer in java .i know how to write in a text file using buffered writer but  when i use it to write in the text file it writes in a single line.i want to write it in the text file  in different line in form of a paragraph.how to do that? please help
0
public class Squarerootguess {
   
    public  static void main(String[] args){
       
        squareRoot(12.0);
       
    }
   
    public static double squareRoot(double m){
          double a;
        a = 144;
       
      // m = 12.0;
        double guess;
        guess = 72.0;
       
        while (guess >= m){
            System.out.println(guess);

              if (guess >= m) {
                     double x ;
                        x = (guess + (a/guess))/2;
                       // System.out.println(x);
                        guess = x;
              }else  {
                System.out.println("Mission LOOP accomplised");
  }
      }
            return m;
    }
    }
0
I have an idea to make a Java App so that it can run on lots of PC platforms...

https://www.experts-exchange.com/questions/29075330/Java-client-app-and-PCI-compliance.html

But as a C# .NET developer, should I seriously consider using .NET CORE?

I need Mac, Windows at least. My target customers will generally be typical users. I guess I should support LINX too.

Should .NET CORE be option instead of Java?

Thanks.
0
I am trying hard to find a way to automate some calculations on a credit card merchant statement. But I must be 100% within the letter and the intent of the rules which define PCI compliance.

Writing a Java app to run on all platforms was a great suggestion to "pre-process" the data, redacting private data, before upload to my site for further processing. But, I wonder, why not do ALL the processing via a downloadable Java App?

Is that a guarantee that I am 100% PCI compliant?

The problem will be when it fails a user and they need it debugged...I would need that PDF file sent to me for debugging. BUT, isn't that a much safer route to take than putting it on a website?

I would certainly have a high security bar to maintain regarding how I handle my PC, and maybe the methodology I use when choosing a password for that email account. But NOT having a website where any Credit Card info resides seems like a smarter way to go.

So, I am now imaging a simple website, probably WordPress. I would post a current version of the Java App for download and explanation of what it does, etc.

Users could download it and privately process their merchant account report on their own PC's. In the LIKELY event they have an unsupported report format, they could email me their full report. (Redacting private data from a PDF itself seems like a pretty high bar for users to handle)

On receipt of the PDF, I would redact all private data for that statement, and delete all un-redacted…
0

Java

99K

Solutions

32K

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.