Java

98K

Solutions

59

Articles & Videos

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

Hello,
 
I'm a seasoned software developer, but my experience with Java extends only a few years. Last year I embarked on creating a GUI for one of our company-specific data stores. I chose JavaFX as the GUI framework.
 
To position user controls onto a screen, the most appropriate widget for one of my layouts appeared to be a GridPane. JavaFX has one built in, but I prefer the wrapper with the same name, that is part of JFXtras.
 
In this GridPane, I placed a generic Label control. It is meant to receive texts of varying lengths. And when it receives a text larger than can fit, I want that Label to grow in size, and make the entire Scene Graph (i.e. GridPane, Scene and Stage) grow with it.
 
Thus far I have set properties and invoked methods that looked like they would allow for that, to no avail.
 
How can I make this happen?
0
Transaction Monitoring Vs. Real User Monitoring
LVL 1
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Hello,

I am using self written Java programmes at home that consume SOAP web services from my rc plane club. So far everything works good, But sometimes the SOAP web services that I use are not available due to maintnance or problems at the club's server. I want to monitor the availability of the SOAP services and persist the status. When I use the SOAP services the programme shall first check the availability from the monitor and if the status is 'available' perform the desired request or else queue the request until the service becomes available again.

Before I start to re-invent the wheel and write my own monitor I wanted to know if there are already tools that can accomplish this task, which can be easily embedded or used in Java before a request.

Best regards,
CB
0
#TodayILearned that #OData presents a problem for #XSLT. The #JSON element named "@odata.context" can't be translated into an #XML element with the same name, using XSLT 2 or 3 as provided in #Java by #Saxonica.
 
The problem is that XSLT uses that @ in XPATH statements to match element attributes, and in other places within curly brackets, like {@attribute}, to copy that attribute's content into the output.
 
The solution is to differentiate between nodes/attributes that do, and ones that don't contain an @-sign,  and either replace() or translate() that into something else.
 
In my case, I use fx:json-to-xml() from XSLT3, implemented by Saxonica, to transform received JSON-formatted data into raw XML. This leads to a map element that contains elements array, boolean, map, null, number, and string. The JSON element names become the XML elelements' "@key" attribute.
 
A 2nd XSL transformation produces the domain-specific XML-format. As stated above, we must take heed with producing the "@odata.context" element. This can occur, a.f.a.i.k., in either a null element or a string element. So, we differ between those with and without an "@" in the key attribute:
 
Without:
<xsl:template match="xf:string[@key][not(contains(@key, '@'))]">
<xsl:element name="{@key}">
<xsl:value-of select="text()" />
</xsl:element>
</xsl:template>
 
With:
<xsl:template match="xf:string[@key][contains(@key, '@')]">
<xsl:variable name="newName"><xsl:value-of select="translate(@key, '@', '')" …
0
 

Author Comment

by:A.E. Veltstra
Hi, Andrew Leniart. Funny, we have the same first name.
 
Thank you for your concern. I did search before I found a way to solve my problem and published it. As far as the search could tell me, I'm literally the first person to encounter and solve this problem. Hence the publication.
0
 
LVL 10

Expert Comment

by:Andrew Leniart
My apologies Andrew, I didn't read your entire post carefully enough and took it to be a problem you were still trying to solve. I think the hash tag # at the start threw me off! These new fandangled ways you younger generation have of talking can get confusing for oldies like me! lol..

Cheers :)
1
Hi Experts,
Trying to build and deploy a war file using Gradle on Tomcat...for one of my POC.

could you give me some lead pls
0
We have Double.isInfinite(), float.isInfinite(), why dont we have that for Integers ?, I think they shud, irrespective of any reasons
0
In a book i'm reading, it shows below code and states: if 'data' isn't defined as a volatile var, other classes might access it before it's completely initialized.  Can someone explain this statement to me. There's nothing else written about it.
class StockData {}
class StockExchange {
      static volatile StockData data = null;
      static void loadStockData () {
            //load and initialize reference variable data. the variable data is written to only once
      }
}
class BuyStocks {
      public void buy () {
            if (StockExchange.data != null) {
                     //analyze data
                    //buy stock
            }
      }
}
0
Hi,

When I try to login to to Google on my PC using ANY of the latest browsers (Chrome, Firefox, Opera etc) I am able to enter my username but when I press the "NEXT" button nothing happens.  I added a screenshot of the page that I am stuck on here:  http://i.imgur.com/zMpNrFM.jpg and the link I am stuck on is below.    The link that i am stuck on is https://accounts.google.com/signin/v2/identifier?hl=en&%3B&flowName=GlifWebSignIn&flowEntry=ServiceLogin

If I use an old Safari browser that is unsupported or I add a Script Blocker to one of the new browsers (like NoScrip) then I get the old Google V1 Login page and I can login with no problems. See image: http://i.imgur.com/A9YlIYy.jpg

Can someone help me figure out how to fix this issue?

Sincerely,

David S.
0
#TodayILearned a #gotcha with #Predicate in #Java. You can learn, too!
 
Here's 1 way to write a Predicate:
 
static Predicate<String> isEmpty() {
    return p -> 0 == p.length();
}

And here's another way:
 
static Predicate<String> isEmpty = (p) -> {
    return 0 == p.length();
}
 
Erm. What's the difference?
 
Well. The first is a method that generates a function, and you call it like this:
 
boolean test = isEmpty().test("Hello!");
 
Or, from a stream in a method in a class named World:

.filter(World::isEmpty())
 
The second is a field with a pregenerated function, and you call it like this:
 
boolean test = isEmpty.test("Hello!");
 
Or, from a stream in a method in a class named World:

.filter(World.isEmpty)
 
Notice how the method-based Predicate still has to generate a function, and thus has to be called with parentheses.
 
The field-based predicate already generated its function by the time it gets called, and because it's a field, no parentheses are used for accessing it.
 
Why Predicates at all, rather than a simple boolean-returning method?
 
Beats the heck out of me. 
2
Hello Experts,

I have a Java applications that uses FileVisitor to walk the directories and read each file looking for a pattern using Scanner’s findWithinHorizon method. Once a match is made, the program stops searching the current directory and moves on to the next one. The issue I’m having is that it takes up too much memory and the program can’t complete a search without throwing an OutOfMemoryExeption. Does anyone have a way around the out of memory exception?

Thank you!

Fox

here is the code::

private java.util.List<String> searchFiles2(String FilePath, final String pattern) throws FileNotFoundException, AccessDeniedException
    {
        File file = new File(FilePath);
        if (!file.isDirectory()) {
            throw new IllegalArgumentException("file has to be a directory");
        }

        final List<String> FoundDirectories = new ArrayList<String>();
        try {
            Path startPath = Paths.get(FilePath);
            Files.walkFileTree(startPath, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path file, final BasicFileAttributes attrs)  throws IOException {
                    try {
                        final String name = file.getFileName().toString();
                        // skip hidden files:
                        if (name.startsWith(".") || new File(file.toString()).isHidden()) {
                            return …
0
I'm trying to collect data from FireBase, in Android Studio, while sorting it using the orderByChild and equalTo functions. Then I'm trying to display the data on text views. The page crashes every time? How can I fix this? Below I've given my code and my database:

 public class TrackOrder extends AppCompatActivity {

    DatabaseReference mDatabase;
    private EditText trackText;
    private Button trackBtn;
    private TextView disp, text;


    public void trackBtn (View view){ //opens the admin portal activity
        trackText = (EditText) findViewById(R.id.trackText);
        disp = (TextView) findViewById(R.id.disp);

        String trackNumb = trackText.getText().toString();

        disp.setText(trackNumb);


    }


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

        String numb = disp.getText().toString();

        trackText = (EditText) findViewById(R.id.trackText);
        text = (TextView) findViewById(R.id.text);
        trackBtn = (Button) findViewById(R.id.trackBtn);


        mDatabase = FirebaseDatabase.getInstance().getReference().child("Orders"); //Reflecting where the data will be located


        mDatabase.orderByChild("1 order_number").equalTo("4725");

        mDatabase.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {



        

Open in new window

0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi all,

Need to write a python or shell script for email alert on memory utilisation of the server.
we are glance tool to monitor the cpu and memory utilisation for our weblogic servers. If the memory utilisation reached 80% it should alert us through mail so that we can check and restart if required.

below is the output of glance file
B0000A Glance C.04.70.000       04:56:38    x86_64                                                                     Current  Avg  High
------------------------------------------------------------------------------------------------------------------------------------------------------
CPU  Util   SU                                                                                                                       |  1%    3%   27%
Disk Util                                                                                                                            |  0%    0%    7%
Mem  Util   U                      UB     B                                                                                          | 26%   26%   26%
Swap Util                                                                                                                            |  0%    0%    0%
------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                     PROCESS LIST                     …
0
How could i provide security in webservice(authentication)
0
I have been using JDK 9 on Windows 10 x64 for a while but when I went to install the latest early release (b174), I first uninstalled the previous version (as usual) and then ran the new installer.

It fails with a message box saying "Another Java installation is in progress. You must complete that installation before you can run this installer".

It seems there are some artifacts around causing the problem but only for JDK 9 as I can uninstall & reinstall JDK 8 without any issues. Also, the same problem occurs if I try to run the installers for any prior JDK 9 releases as well (even though they worked before).

Searches have suggested various options like using a Microsoft MSI clean-up tool and registry hacks but nothing is helping.

Can anyone suggest a way to get JDK 9 installed (as now I cannot use any release of JDK 9 at all)?
0
Hey

My users have to use a website - the developer of the website say I have to set: _JAVA_OPTIONS=-Xmx1024m (env. variable on the machines)

When setting the env. variable the website works, but other java-applets does not work anymore. (for example verify java)

How to solve this?

Mike
0
Should I use Ecllispe or Android Studio to develop Android application ? Any good resource for starter to build an Android application ?

Thx
0
I am working on a migration project, from PB to Java.
I am getting a rounding issue when comparing Java with PB.
Example: Please find the below combinations with scale 2
Number                PB
123.4445      123.45
123.4444      123.44
123.4454      123.45
12.344445      12.34
12.34454      12.35
12.34544      12.35

In PB considering 2 numbers after scaling decimal, is it true or what type of rounding happening here.
I have tried in Java with all Bigdecimal rounding types and mathcontext but there is no luck.
Could you please explain me how rouning works in PB.
0
Hi Experts,

I have jenkins installed on my windows desktop and having issues configuring it to send emails from my outlook account as it uses TLS instead of SSL. I have done some research and some forums suggested adding the JENKINS_JAVA_OPTIONS to the jenkins.xml file and doing a restart however this didn't work for me.

JENKINS_JAVA_OPTIONS      -Djava.awt.headless=true -Dmail.smtp.starttls.enable=true

My SMTP settings are
SERVER smtp-mail.outlook.com
SMTP PORT 587
Use SSL unchecked
Username *****
Password ******

Error is below
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first


      at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)

      at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1580)

      at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1097)

      at javax.mail.Transport.send0(Transport.java:195)

      at javax.mail.Transport.send(Transport.java:124)

      at hudson.tasks.Mailer$DescriptorImpl.doSendTestMail(Mailer.java:581)

      at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)

      at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)

      at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
0
When i was trying to execute the query errors like
ORA-00900: invalid SQL statement
I am unable find a solution.Please help.
0
Hi,

Is it possible to extract certain words from multiple documents and then place them in to an excel spreadsheet sort of like a data miner (I guess?).

Example:

Let's assume I need someone with experience in Java and they need at least 3 years experience, I can then type in those requirements and it will then go through all my CV's and put the people it thinks meets those requirements in to a excel spreadsheet.

I'm sure this is possible but I'm not sure how hard this would be (I'm doing this for a school project)

Thanks,
James
0
Revamp Your Training Process
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

I have large numbers PDF document, from which I need to extract text. The extracted text I use for further processing. I did this for a small subset of documents using Tesseract API in a linear approach and I get the required output. However, this takes a very long time when I have a large number of documents.

I tried to use the Hadoop environment processing capabilities (Map-Reduce) and storage (HDFS) for solving this issue. However, I am facing problem to implement Tesseract API into the Hadoop (Map-Reduce) approach. As Teserract converts the files into intermediate image files, I am confused as to how intermediate result Image files of Tesseract-API-process can be handled inside HDFS.

I have searched and unsuccesfully tried a few options earlier like:

    I have extracted text from PDF by extending FileInputFormat class into my own PdfInputFormat class using Hadoop-Map-Reduce, for this i used Apache PDFBox to extract text from pdf, but when it comes to scanned-pdf's which contains image, this solution does not give me the required results.

    I found few answers on the same topic stating to use -Fuse and that will help or one should generate image files locally and than upload those into hdfs for further processing. Not sure if this is the correct approach.

Would like to know approaches around this.
0
I am trying to monitor a java application (jenkins) using JAVA Melody. I need a groovy script that can monitor for values highlighted in RED for columns in mean time and mean cpu times.

Below is the link to java melody (monitoring) plugin in jenkins.

Jenkins plugin.

Sample scripts
0
Hello,

I am a beginner with this, and after configuring JAVA and Wildfly, I get the following error when trying to run standalone.sh :

14:27:33,895 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
        at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131) [wildfly-controller-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.server.ServerService.boot(ServerService.java:357) [wildfly-server-2.2.0.Final.jar:2.2.0.Final]
        at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:299) [wildfly-controller-2.2.0.Final.jar:2.2.0.Final]
        at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_131]
Caused by: com.ctc.wstx.exc.WstxParsingException: Received non-all-whitespace CHARACTERS or CDATA event in nextTag().
 at [row,col {unknown-source}]: [87,9]
        at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:614) [woodstox-core-asl-4.4.1.jar:4.4.1]
        at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:487) [woodstox-core-asl-4.4.1.jar:4.4.1]
        at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:472) [woodstox-core-asl-4.4.1.jar:4.4.1]
        at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1174) …
0
I have an expandable list view that is inside of an expandable list adapter. I would like to remove an item from an expandable list view when the delete option is selected in the context menu in Android. After I call the remove method on the object's position, when I try to call notifyDataSetChanged() on the expandable list adapter, it says the method does not exist.

However, it will work for a regular ArrayAdapter. Because of the way my data is structured (having to display multiple fields in each list view item), I need to use an expandable list view instead of just a simple list view. I have tried casting the expandable list adapter to an ExpandListAdapter object and calling the getAdapter() method on it, and then calling notifyDataSetChanged() but I get the following error: SimpleAdapter cannot be cast to com.test.myapp.ExpandListAdapter.

My application is using API 25. Please see the code below:
@Override
public boolean onContextItemSelected(MenuItem item) {

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch(item.getItemId()) {
        case R.id.add:
            Intent intent = new Intent(MainActivity.this, AddUser.class);
            startActivity(intent);
            return true;
        case R.id.edit:
            Intent intent2 = new Intent(MainActivity.this, ViewUser.class);
            intent2.putExtra("data", userList.get(info.position).get("id"));
            startActivity(intent2);
 

Open in new window

0
padserver/padErr.txt

==> /usr/local/pad/padserver/padOut.txt <==

---- java.library.path   ../lib/dll;/usr/local/pad\lib\dll\sys32

---- java.ext.dirs   /usr/java/jdk1.7.0_79/jre/lib/ext:/usr/local/pad/lib/ext



 checkFileInPath jspWin.dll   exists false

 checkFileInPath x25lyra.dll   exists false




==> /usr/local/pad/padserver/padErr.txt <==

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space


Hi Experts

we get above Java heap space error on our servers due to this we face other issues on server. kindly help.
0
Hi, following along on a tutorial on using Netbeans debugger. However, when I set a break point then click to debug and then try to use the Step Into (F7) command a windows opens up with a name like InputStreamReader.java and I am out of the debugger.

The code used for this tutorial  has a variable that is set from a user input and the only error I see is
"Variable Information not available, source compiled without -g

I am using a virtual machine built in VMWare Pro 12. Not sure if that has anything to do with it. At any rate I am not able to step into.
0

Java

98K

Solutions

59

Articles & Videos

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.