Java – Can Mobile Games Use Fragments Instead of SurfaceViews?

All tutorials for Android mobile games (like this one) use the to display game objects. Most other applications usually use one Activity > Layout Resource architecture.

The guide explains why he uses a Activity > SurfaceView Subclass Architecture because of threading and canvasing at this point in the video.

  • Could you use fragments to perform threading and viewing game objects?
  • If so, why is a SurfaceView preferred?

RTSP stream in Java application

Could someone tell me how to integrate RTSP stream (from my IP camera that uses both user and passwd authentication) into my Java-based application? Are there free libraries that could do the trick? At this moment I have researched a lot and the idea I have is to use favaFx webView to open web pages created by FFmpeg running on an Ubuntu server. The only problem is that I do not really know how to tell the FFmpeg that this is my RTSP link, and just give me a kind of HLS link to paste into WebView from JavaFx. If you know a simple solution for creating a Java frame with RTSP stream, please let me know. Thank you for advice!


I'm a beginner and I have a very fundamental doubt about the eclipse. My colleague sent me the code for our work, which includes a graphical interface, but I do not know where to access the component window (caption, button, etc.) to make some changes. I used Netbeans and I do not know how to use Eclipse properly. Thanks in advance

java – How to Get a Frame from the Android Studio Camera

I'm new to Android Studio and Java, and I need to create an app that scales a camera frame down to 128×128 and converts all pixels into grayscale and then to solid black and full white, and then sets the value to a 128-size Boolean array
Example: Array [128] = [false, false, true, true, false …]
I already know more or less how to do this recognition using bitmaps, but I do not know how to create a camera bitmap. Basically, I want a gap that is called 30 times per second and that contains the code that contains a camera frame bitmap format, it does not necessarily have to be 30 times a second and I think it's easier to have a grayscale image but it does not necessarily have to be grayscale. I hope you understand, obs if you can explain where the code is I guess.

the app runs on a sansung galaxy j5 prime 2 with android 8.0.0

I hope to be able to view the bitmap in an image view, just to know if the return bitmap is OK, and for the time being all the code I tested has just crashed the application.

ubuntu – Why does systemd-resolve stop my java server?

I came across this problem where every few days one of my Java servers is dying. To find out why, I ran cat /var/log/syslog which produces:

Sep 21 06:36:24 ip-172-31-42-5 systemd-timesyncd(16235): Network configuration changed, trying to establish connection.
Sep 21 06:36:24 ip-172-31-42-5 systemd-timesyncd(16235): Synchronized to time server (
Sep 21 06:46:45 ip-172-31-42-5 systemd(1): Starting Daily apt upgrade and clean activities...
Sep 21 06:47:35 ip-172-31-42-5 kernel: (5731409.370359) systemd-resolve invoked oom-killer: gfp_mask=0x14200ca(GFP_HIGHUSER_MOVABLE), nodemask=(null), order=0, oom_score_adj=0
...(skipping a bunch) ...
Sep 21 06:47:35 ip-172-31-42-5 kernel: (5731409.370580) Out of memory: Kill process 28251 (java) score 368 or sacrifice child
Sep 21 06:47:35 ip-172-31-42-5 kernel: (5731409.374244) Killed process 28251 (java) total-vm:2613628kB, anon-rss:178048kB, file-rss:0kB, shmem-rss:0kB
Sep 21 06:47:35 ip-172-31-42-5 kernel: (5731409.403233) oom_reaper: reaped process 28251 (java), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

After reading this post, I learned that the oom_reaper stops the largest memory-intensive process when any process tries to allocate too much memory. Well, I suspect that systemd-resolve trying to request a ridiculous amount of memory, and then the reaper stops my bad java process.

I could handle that by putting it down vm.oom_kill_allocating_task As suggested in the link above, I'm trying to figure out why systemd-resolve is trying to request such an absurd amount of memory. Does anyone know what the basic problem is here?

Edit: When the Java server is running, memory usage is only 234M / 460M

api – OAuthException error in Java with restfb

I've written a small code with restfb api and to get the access token that publishes the same post in the groups specified in the code. To prove it, I used two groups, one of mine and another I joined. When I use the program to post one of these groups, the post is uploaded to the group I created, but not to the group I joined because of an authentication problem or the like. Does anyone know what it is and how to fix it? Here I leave the program code and the error that triggers me, thank you.


    package facebook;
    import com.restfb.DefaultFacebookClient;
    import com.restfb.FacebookClient;
    import com.restfb.Version;
    import com.restfb.Connection;
    import com.restfb.Parameter;
    import com.restfb.types.FacebookType;
    import com.restfb.types.Group;
    import java.util.List;
    import java.util.Scanner;
    public class Facebook {
        public static void main(String() args) throws FileNotFoundException {
            Scanner in = new Scanner(;
            String gps() = {"2500111856890268", "1102727843098919"};
            String accessToken = "aca va el token de acceso";
            FacebookClient fbClient = new DefaultFacebookClient(accessToken, 
            Connection result = fbClient.fetchConnection("me/groups", 
            Group aGroup = new Group();
            System.out.print("Inserta el mensaje a publicar:n   ");
            String msg = in.nextLine();
            for (String gp : gps) {
                FacebookType response = fbClient.publish(aGroup.getId()+"/feed", 
                FacebookType.class, Parameter.with("message", msg));
                System.out.println("Si queres ver el post entra aca: " + 


Inserta el mensaje a publicar:
Si queres ver el post entra aca: /* este seria el link para entrar al post en el grupo q cree yo, pero al momento de intentar publicarlo en el grupo al que me uni, tira el siguiente error: */
Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#200) If posting to a group, requires app being installed in the group, and 
          either publish_to_groups permission with user token, or both manage_pages 
          and publish_pages permission with page token; If posting to a page, 
          requires both manage_pages and publish_pages as an admin with 
          sufficient administrative permission (code 200, subcode null) 'null - null'
    at com.restfb.exception.generator.DefaultFacebookExceptionGenerator$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(
    at com.restfb.exception.generator.DefaultFacebookExceptionGenerator.throwFacebookResponseStatusExceptionIfNecessary(
    at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(
    at com.restfb.DefaultFacebookClient.makeRequest(
    at com.restfb.DefaultFacebookClient.publish(
    at com.restfb.DefaultFacebookClient.publish(
    at facebook.Facebook.main(
C:UsersxxxAppDataLocalNetBeansCache8.2executor-snippetsrun.xml:53: Java returned: 1
BUILD FAILED (total time: 6 seconds)

Java – How do I add lighting to a 2D tile-based game in JavaFX?

With Java and JavaFX I create a roggenartiges 2D tile game. I'm currently working on adding light and darkness to the dungeon, but if I try to do it, it will take a long time to load and eventually it will fail due to lack of memory.

Here is

package sample;

import static sample.World.worlds;

public class Lighting {
    public static void calculateLighting(int wn, int skyLighting) {
        Block()()() world = worlds(wn);
        for (int z = 0; z < worlds(; z++) {
            for (int y = 0; y < worlds(; y++) {
                for (int x = 0; x < worlds(; x++) {
                    Block b = world(x)(y)(z);
                    b.light = skyLighting;
                    if (b.embID == 1) { //test if a block has a torch attached to it
                        for (int distance = 0; distance <= 15; distance++) {
                            for (int x1 = x - distance; x1 < x + distance; x1++) {
                                for (int y1 = y - distance; y1 < y + distance; y1++) {
                                    for (int z1 = 0; z1 < worlds(; z1++) {
                                        try {
                                            world(x1)(y1)(z1).light += 1;
                                        } catch (ArrayIndexOutOfBoundsException ignored) {

        for (int z = 0; z < worlds(; z++) {
            for (int y = 0; y < worlds(; y++) {
                for (int x = 0; x < worlds(; x++) {
                    Block b = world(x)(y)(z);
                    if (b.light > 15) {
                        b.light = 15;

                        //If your number X falls between A and B, and you would like Y to fall between C and D, you can apply the following linear transform:
                        //Y = (X-A)/(B-A) * (D-C) + C
                        //(worlds( * (1-0.5) + 0.5
                        if (b.sprite != null) {
                            b.sprite = ImgManip.darken(b.sprite, (worlds( / (15d) * (1 - 0.5) + 0.5);

This means that it first finds flares in the world and then increases the brightness of each block around it, depending on how far away the torch is. Then it takes the sprite of each block and darkens it with the darken() Method. That's why it takes so long. If I just comment that out, it works fine, but the lighting is not there.

Here is the darken() Method:

public static Image darken(Image image, double amount) {
        PixelReader pixelReader = image.getPixelReader();
        WritableImage writableImage =
                new WritableImage(
        PixelWriter pixelWriter = writableImage.getPixelWriter();

        for(int y=0; y```

Why has C ++? Undefined behavior & # 39; and other languages ​​like C # or Java not

Undefined behavior is one of the things that was only recognized as a very bad idea in retrospect.

The first compilers were great hits and fortunately welcomed improvements over alternative machine language or assembly language programming. The problems involved were known, and high-level languages ​​were specifically invented to solve these known problems. (The enthusiasm at that time was so great that HLLs were sometimes referred to as "the end of programming" – as if from now on we'd just have to write trivially what we wanted, and the compiler would do all the real work.)

Only later did we recognize the newer problems that accompanied the newer approach. If you are not on the computer that runs the code, there is a chance things will not silently do what we expected them to do. For example, assigning a variable would typically leave the initial value undefined; This was not considered a problem because you would not assign a variable if you did not want to store a value in it, or? Surely it was not too much to expect that professional programmers would not forget to assign the initial value, right?

It turned out that with the larger codebases and more complex structures made possible by more powerful programming systems, many programmers actually make such mistakes from time to time and the resulting undefined behavior has become a major problem. Even today, the majority of vulnerabilities, from tiny to terrible, are due to undefined behavior in one form or another. (The reason for this is that undefined behavior is usually very much determined by things at the next lower computer level.) Attackers who understand this level can use that latitude to make a program, not just unintentional things, but accurate to do things she want.)

Since recognizing this, there has been a general urge to banish undefined behavior from high-level languages, and Java has been particularly thorough in this regard (which was relatively simple, since it was designed to run on a custom virtual machine anyway). Older languages ​​like C can not be easily upgraded without losing compatibility with the vast amount of code available.

java – Why my app crashes every time I start the logcat, suggest what to do. I'm new to Android development

2019-09-21 17: 27: 28.662 678-704 / in.gntex.ecommapp D / FA: Message logging enabled at debug level
2019-09-21 17: 27: 28.668 678-678 / in.gntex.ecommapp D / Android Runtime: Shutting down the VM
2019-09-21 17: 27: 28.670 678-678 / in.gntex.ecommapp E / Android Runtime: FATAL EXCEPTION: main
Process: in.gntex.ecommapp, PID: 678
java.lang.RuntimeException: Activity ComponentInfo {in.gntex.ecommapp / in.gntex.ecommapp.SplashActivity} can not be started: android.view.InflateException: Binary XML file Line 2: Binary XML file Line 2: Error occurred Inflating the class Android
at (
at (
at (
at $ H.handleMessage (
at android.os.Handler.dispatchMessage (
at android.os.Looper.loop (
at (
at java.lang.reflect.Method.invoke (native method)
at $ (
at (
Caused by: android.view.InflateException: Line 2 of the binary XML file: Line 2 of the binary XML file: Error inflating the android class
Caused by: android.view.InflateException: Binary XML file Line 2: Error inflating the android class
Trigger: java.lang.ClassNotFoundException: The class "" was not in the path "DexPathList ((zip-file" /data/app/in.gntex.ecommapp-2/base.apk"),nativeLibraryDirectories ") found = (/ data / app / in.gntex.ecommapp-2 / lib / poor, / system / lib, / vendor / lib))
at dalvik.system.BaseDexClassLoader.findClass (
at java.lang.ClassLoader.loadClass (
at java.lang.ClassLoader.loadClass (
at android.view.LayoutInflater.createView (
at android.view.LayoutInflater.onCreateView (
at (
at android.view.LayoutInflater.onCreateView (
at android.view.LayoutInflater.createViewFromTag (
at android.view.LayoutInflater.createViewFromTag (
at android.view.LayoutInflater.inflate (
at android.view.LayoutInflater.inflate (
at android.view.LayoutInflater.inflate (
at (
at (
at in.gntex.ecommapp.SplashActivity.onCreate (
at (
at (
at (
at (
at (
at $ H.handleMessage (
at android.os.Handler.dispatchMessage (
at android.os.Looper.loop (
at (
at java.lang.reflect.Method.invoke (native method)
at $ (
at (

50% off Java Hosting – JSP, Java, J2EE, Tomcat, Servlets and dedicated JVM has offered budget-friendly Java hosting since 2008.
We are a UptimeSafe certified provider. Contact us through our website or by contacting

Private JVM Java Hosting Package includes:

  • Pure SSD hosting
  • Dedicated JVM – no sharing of JVM
  • Monthly / weekly backup service
  • Multiple WAR applications and multiple domains
  • Ant and maven
  • Apache Tomcat every version
  • SSH access
  • JDK any version
  • Java Control Panel to restart Tomcat, change the Tomcat / JDK version, monitor memory usage, etc.
  • Servlets, JSP, JSF, Spring, Hibernate, JSTL, Struts, Grails, EJB 3.0 and more
  • Update the heap size at any time by 5 USD / month for 128 MB. 30% discount for 256MB addon
  • Databases: MYSQL 5.6 PostgreSQL 9.3, MongoDB, CouchDB
  • CVS / Subversion (SVN) / GIT / Mercurial Repository
  • PHP 7, Python 3, Perl, Ruby
  • Free subdomain / alias
  • All typical cPanel functions

Private hangover

  • Hard disk space (SSD): 10 GB
  • Heap size: 160 MB
  • Perm Size: 160 MB
  • Traffic: 1 TB
  • Monthly: $ 9.99

Private Tomcat Pro

  • All features of Private Tomcat
  • HeapSize: 320 MB
  • Perm Size: 320MB
  • Monthly: 19.99 USD
  • Recommended for Grails, Cyclos and other complex frameworks or webapps

We offer a custom Java Control Panel. You will have the ability:

  • Change the Tomcat version
  • Start / Stop Tomcat
  • Change the JDK version and several JVM startup parameters
  • Search Tomcat logs
  • Access Tomcat Manager
  • Monitor JVM memory usage
  • Managing JMX / RMI access for remote JConsole, JVISUALVM, and more.
  • Quickly check JDBC connections to MySQL and PostgreSQL
  • List port usage and more

50% recurring discount coupon for Tomcat and Tomcat Pro packages ordered in September / October 2019: WHT50P14 (for new customers only)

For those of you who need more heap memory (320 MB +), we offer VPS packages with SolusVM Control Panel. Each VPS comes with a base operating system or preinstalled open source software.
Dedicated servers are also available.

The most commonly requested setups for VPS packages include JDK, Database Server, SVN and Jira, Jenkins, Magnolia, Liferay, OpenCMS, Confluence, Alfresco, JPublish, Glassfish, Cyclos, Openfire and OpenBravo. WHM / cPanel, Webmin / Virtualmin, DirectAdmin or ISPConfig3 can also be preinstalled. There are also dedicated servers available.

Check for more.