Why does Eclipse say that "errors exist" but shows nothing in console?
Asked Answered
G

4

14

I am using Eclipse to build a program and when I go to run it, it says that "errors exist", I run it anyway, there are no errors showing up in the console and the application runs a blank screen. Why is this?

Additional Info: I recently have been trying to change my previous layout, from a very crude form, to utilizing GridBagLayout, however i am not very familiar with using layouts. I strongly suspect the problem lies in, or revolves around, my layout since the program properly functioned before I tried making changes.

Here are my two main classes that involve the layout, sorry for it being messy, I commented out a lot of lines that worked for the previous layout in case I have to revert back to it:

import java.awt.*;
import java.sql.SQLException;
import java.util.LinkedList;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ColorUIResource;

import java.sql.*;

public class MainDisplay extends JFrame {

static Toolkit tk = Toolkit.getDefaultToolkit();
static int Width = (int)tk.getScreenSize().getWidth();
static int Height = (int)tk.getScreenSize().getHeight();

//public static JFrame frame = new JFrame();
public static JPanel pane = new JPanel();


private static String targetIpHolder;
private static String attackerIpHolder;
private static int threatLevelHolder; 
private static String numAttacksHolder;

public static void main (String[] args) {
new MainDisplay();

}

public MainDisplay() {


setPreferredSize(new Dimension(Width, Height));
setLocation(0,0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUndecorated(true);



//pane.setLayout(gridBag);
setLayout(new BorderLayout());
//add(pane, BorderLayout.CENTER);
pane.setBounds(0,0, Width, Height);

pack();
setVisible(true);

ThreatPanel Run = new ThreatPanel();
Database Data = new Database();

//Create Connection to Database and run query

Data.createConnection();
Data.getData();
    try {
        while(Data.rslt.next()){
            Data.process();
            targetIpHolder = Data.getTarget();
            attackerIpHolder = Data.getAttacker();
            threatLevelHolder = Data.getThreat_level();
            numAttacksHolder = Data.getNum_attack();
            //System.out.println(targetIpHolder);
            //System.out.println(attackerIpHolder);
            Run.ShowThreats();
            try {
                Thread.sleep(1000*1); 
            } catch (InterruptedException e) {

                e.printStackTrace();
            }

        }
    } catch (SQLException e) {

        e.printStackTrace();
    }



}

public static String getTargetIpHolder(){
return targetIpHolder;
}
public static String getAttackerIpHolder(){
return attackerIpHolder;
}
public static int getThreatLevelHolder(){
return threatLevelHolder;
}
public static String getNumAttacks(){
return numAttacksHolder;
}

}

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.image.RenderedImage;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;


import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;



public class ThreatPanel {

JPanel BackPanel = new JPanel();
//JPanel HeadingBreak = new JPanel();
JPanel DarkPanel = new JPanel();
//JPanel HeadingBreak = new JPanel();
//JPanel HorizontalSplit1 = new JPanel();
//JPanel HorizontalSplit2 = new JPanel();
//JPanel VerticalSplit = new JPanel();

public GridBagLayout gridBag = new GridBagLayout();
public GridBagConstraints gbc = new GridBagConstraints();


final int TEST = 0;
final int TEST2 = 100;
final int TEST3 = 200;

private String city;
private String region;
private String latitude;
private String longitude;
private Image img;
private ImageIcon icon;

Color severeColor = new Color(225,102,00);

URL geoLocRetriever;


//Target area declarations. 
String Client = "CLIENT"; //filler
JLabel Target = new JLabel("TARGET");
JLabel ClientLabel = new JLabel(Client); //filler
JLabel TargetServerData;
JLabel ServerID = new JLabel("SERVER ID");

//Attacker area declarations.
JLabel Attacker = new JLabel("ATTACKER");
JLabel AttackerData;
JLabel GeoLocData;
JLabel GeoLocImg;
JLabel GeoLocLabel = new JLabel("GEO LOCATION");

//Threat Level area declarations.
JLabel ThreatLevel = new JLabel("THREAT");
JLabel ThreatLevelData;

//Number of Attacks declarations
JLabel NumberOfAttacks = new JLabel("ATTACKS");
JLabel NumberOfAttacksData;


public ThreatPanel()
{
DarkPanel.setLayout(gridBag);

TargetServerData = new JLabel();
AttackerData = new JLabel();
ThreatLevelData = new JLabel();
NumberOfAttacksData = new JLabel();
GeoLocData = new JLabel();
GeoLocImg = new JLabel();


BackPanel.setLayout(null);
BackPanel.setBackground(Color.WHITE);
BackPanel.setBounds(0,0, MainDisplay.Width, MainDisplay.Height);
BackPanel.setOpaque(true);
/*
HeadingBreak.setBackground(Color.WHITE);
HeadingBreak.setBounds(0, 80, MainDisplay.Width, 3);
HeadingBreak.setOpaque(true);
*/
/*
HorizontalSplit1.setBackground(Color.WHITE);
HorizontalSplit1.setBounds(0, MainDisplay.Height/2, MainDisplay.Width, 3);
HorizontalSplit1.setOpaque(true);
*/
/*
HorizontalSplit2.setBackground(Color.WHITE);
HorizontalSplit2.setBounds(0, MainDisplay.Height/2+80, MainDisplay.Width, 3);
HorizontalSplit2.setOpaque(true);
*/
/*
VerticalSplit.setBackground(Color.WHITE);
VerticalSplit.setBounds((int)(MainDisplay.Width/1.5), 0, 3, MainDisplay.Height);
VerticalSplit.setOpaque(true);
*/
//Target area settings. 

Target.setFont(new Font("Arial", Font.BOLD, 85));
Target.setForeground(Color.GREEN);
Target.setBounds(0, 0, ((int)(MainDisplay.Width/1.5)-3), 75);
Target.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(Target, gbc);

ClientLabel.setForeground(Color.WHITE);
ClientLabel.setFont(new Font("Arial", Font.BOLD, 100));
ClientLabel.setBounds(0, 115, ((int)(MainDisplay.Width/1.5)-3), 95);
ClientLabel.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(ClientLabel, gbc);


TargetServerData.setForeground(Color.WHITE);
TargetServerData.setFont(new Font("Arial", Font.BOLD, 120));
TargetServerData.setBounds(0, 230, ((int)(MainDisplay.Width/1.5)-3), 95);
TargetServerData.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(TargetServerData, gbc);

ServerID.setForeground(Color.WHITE);
ServerID.setFont(new Font("Arial", Font.BOLD, 120));
ServerID.setBounds(0, 230, ((int)(MainDisplay.Width/1.5)-3), 95);
ServerID.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 3;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(ServerID, gbc);

Attacker.setFont(new Font("Arial", Font.BOLD, 85));
Attacker.setForeground(Color.RED);
Attacker.setBounds(0, (MainDisplay.Height/2)+3, ((int)(MainDisplay.Width/1.5)-3), 75);
Attacker.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 4;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(Attacker, gbc);

AttackerData.setForeground(Color.RED);
AttackerData.setFont(new Font("Arial", Font.BOLD, 70));
AttackerData.setBounds(0, ((int)(MainDisplay.Height/1.5)-3), ((int)(MainDisplay.Width/1.5)-3), 75);
AttackerData.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 5;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(AttackerData, gbc);

GeoLocData.setFont(new Font("Arial", Font.BOLD, 70));
GeoLocData.setForeground(Color.RED);
GeoLocData.setBounds(0, (int)(MainDisplay.Height/1.2), ((int)(MainDisplay.Width/1.5)-3), 75);
GeoLocData.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 0;
gbc.gridy = 6;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(GeoLocData, gbc);

ThreatLevel.setFont(new Font("Arial", Font.BOLD, 85));
ThreatLevel.setForeground(Color.GREEN);
ThreatLevel.setBounds(725, 0, ((int)(MainDisplay.Width/1.5)-3), 75);
ThreatLevel.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(ThreatLevel, gbc);

ThreatLevelData.setFont(new Font("Arial", Font.BOLD, 100));
ThreatLevelData.setBounds(725, 105, ((int)(MainDisplay.Width/1.5)-3), 95);
ThreatLevelData.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(ThreatLevelData, gbc);


NumberOfAttacks.setFont(new Font("Arial", Font.BOLD, 85));
NumberOfAttacks.setForeground(Color.RED);
NumberOfAttacks.setBounds(725, (MainDisplay.Height/2)+3, ((int)(MainDisplay.Width/1.5)-3), 75);
NumberOfAttacks.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(NumberOfAttacks, gbc);

NumberOfAttacksData.setFont(new Font("Arial", Font.BOLD, 85));
NumberOfAttacksData.setForeground(Color.RED);
NumberOfAttacksData.setBounds(725, (int) ((MainDisplay.Height/1.5)), ((int)(MainDisplay.Width/1.5)-3), 75);
NumberOfAttacksData.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 3;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(NumberOfAttacksData, gbc);

GeoLocLabel.setFont(new Font("Arial", Font.BOLD, 85));
GeoLocLabel.setForeground(Color.RED);
GeoLocLabel.setBounds(0, (MainDisplay.Height/2)+3, ((int)(MainDisplay.Width/1.5)-3), 75);
GeoLocLabel.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 4;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(GeoLocLabel, gbc);

GeoLocImg.setBounds(1050, 590, 300, 300);
GeoLocImg.setHorizontalAlignment(SwingConstants.CENTER);
gbc.gridx = 1;
gbc.gridy = 5;
gbc.gridheight = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
DarkPanel.add(GeoLocData, gbc);

//Remaining settings.
/*
//DarkPanel.setLayout(null);
//DarkPanel.setBackground(Color.BLACK);
//DarkPanel.setBounds(3, 3, ((MainDisplay.Width)-6), ((MainDisplay.Height)-6));
//DarkPanel.setOpaque(true);
////DarkPanel.add(Target);
//DarkPanel.add(HeadingBreak);
//DarkPanel.add(VerticalSplit);
//DarkPanel.add(HorizontalSplit1);
//DarkPanel.add(HorizontalSplit2);
DarkPanel.add(ClientLabel);
DarkPanel.add(TargetServerData);
DarkPanel.add(ThreatLevel);
DarkPanel.add(ThreatLevelData);
DarkPanel.add(Attacker);
DarkPanel.add(AttackerData);
DarkPanel.add(NumberOfAttacks);
DarkPanel.add(NumberOfAttacksData);
DarkPanel.add(GeoLocData);
DarkPanel.add(GeoLocImg);
*/

BackPanel.add(DarkPanel);

MainDisplay.pane.add(BackPanel, new Integer(0), 0);

}

public void getGeoLoc()
{
String locHolder;
try {
    geoLocRetriever = new URL("http://ip-api.com/line/*******"); //+ MainDisplay.getAttackerIpHolder()
} catch (MalformedURLException e) {
    e.printStackTrace();
}

InputStream stream = null;
try {
    stream = geoLocRetriever.openStream();
} catch (IOException e1) {
    e1.printStackTrace();
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
if (stream != null) try {
    final BufferedInputStream input = new BufferedInputStream(stream);
    final byte[] reader = new byte[16384];
    int r = 0;
    while ((r = input.read(reader, 0, 16384)) != -1)
        buffer.write(reader, 0, r);
    buffer.flush();
} catch(IOException e) {
    e.printStackTrace();
} finally {
    if(stream != null) try {
        stream.close();
    } catch(IOException e) {
        e.printStackTrace();
    }
}


locHolder = new String(buffer.toByteArray());
String[] lines = locHolder.split("\n");
//System.out.print(lines[5]);

city = lines[5];
region = lines[4];
latitude = lines[7];
longitude = lines[8];

String temp;
temp="https://maps.googleapis.com/maps/api/staticmap?center=" +latitude +"," +longitude +"&zoom=7&size=300x300&markers=color:red|label:A|" +latitude +"," +longitude +"&sensor=false";
URL mapurl = null;
try {
    mapurl = new URL(temp);
} catch (MalformedURLException e) {
    e.printStackTrace();
}
try {
    img = ImageIO.read(mapurl);
} catch (IOException e) {
    e.printStackTrace();
}
icon = new ImageIcon(img);  
}

public void ShowThreats(){

    String targetEnd = MainDisplay.getTargetIpHolder();     
    TargetServerData.setText(targetEnd);

    String attackerEnd = MainDisplay.getAttackerIpHolder();
    AttackerData.setText(attackerEnd);

    getGeoLoc();
    String geoLocEnd = city + "," + region;
    GeoLocData.setText(geoLocEnd);
    GeoLocImg.setIcon(icon);


    int threatLevelEnd = MainDisplay.getThreatLevelHolder();
    //System.out.println(threatLevelEnd);
    if ((threatLevelEnd > TEST ) && (threatLevelEnd < TEST2)){
        ThreatLevelData.setText("WARNING");
        ThreatLevelData.setForeground(Color.YELLOW);
    }
    else if ((threatLevelEnd > TEST2 ) && (threatLevelEnd < TEST3)){
        ThreatLevelData.setText("SEVERE");
        ThreatLevelData.setForeground(severeColor);
    }
    else if (threatLevelEnd > TEST3){
        ThreatLevelData.setText("CRITICAL");
        ThreatLevelData.setForeground(Color.RED);
    }
    else{
        ThreatLevelData.setText("ERROR");
        ThreatLevelData.setForeground(Color.PINK);
    }

    String numAttacksEnd = MainDisplay.getNumAttacks();
    NumberOfAttacksData.setText(numAttacksEnd);
    //System.out.println(numAttacksEnd);

}

}
Garrard answered 17/7, 2013 at 22:29 Comment(11)
Open the "Error Log" view to see Eclipse errors. Open up the "Problems" view to see problems with your code or the build process.Linder
might have errors is some other class of your projectKnowitall
no need to downvote, just for my inexperience, I've done prior research before coming hereGarrard
IMO when I found this and I know there's nothing wrong (after reviewing the messages), I just simply ignore them.Selfpossessed
@Pat : Why you using setBounds(...) on the DarkPanel for placing components, when you are using GridBagLayout as its Layout Manager ?Norling
Well @nIcEcOw, I picked this project up from someone else who did most of the GUI work, which I am very new to, and it looked like all the components were being added onto Darkpanel, which then was added to backPanel, which then went into panel in the Main. I could be wrong, I'm not familiar with this stuff. thankyou for looking into my questionGarrard
@Pat : When the Layout Manager is used, actually to a certain extend the programmer is not suppose to use setXxX()/setXxXSize() methods explicitly (barring few Layouts like GroupLayout, Box to a certain extend). That becomes the part of the Layout concern to calculate the preferred size of each component and display it on the view. Though for the rest you're MOST WELCOME and KEEP SMILING :-)Norling
Thanks @nIcEcOw, as I was doing this, in my head I figured I would use the layout manager for the one panel that has all of my components; so if I use one layout manager for a panel, do all panels in that frame, or the frame itself, inherit that specific layout?Garrard
@Pat : Nah, only the JPanel on which it is explicitly set will have it. Layout is attached to a JPanel by using it's setLayout(layoutToAttach) method. By default each JPanel has a FlowLayout attached to itself. JFrame's default is BorderLayout, so when you write frame.add(component), it is very much equal to frame.add(component, BorderLayout.CENTER). A single Layout Manager is sometimes not enough to adjust the components on the view, hence an approach like Nested Layout is used as described hereNorling
Cleaning the project in Eclipse fixes this.Gladysglagolitic
I have the same message, and nothing fixes it. In the Eclipse error log (located thanks to answer below) the only errors are download errors like "Unknown Host: download.oracle.com/otn_software/oepe/12.2.1.9/photon/…" (I'm often working offline.) -- Did I just mess up Eclipse again? :-)Momentum
M
26

Go to Window --> Show View --> general --> Problems and you will see the list of errors. In my case - I had a wrong source folder in Build Path. Configuring Build Path solved the "Error exists in your project" issue. In the 'problems' view - rt click on the error and quick fix- this solved the issue.

Mildred answered 22/3, 2017 at 21:10 Comment(0)
R
4

It may be a JRE error. Right click the project root and select preferences. Come to installed JREs and look for an error. Also, rebuild the project and check Window > Show View > Error Log, as suggested in a comment by @Ted Hopp.

Resinate answered 18/7, 2013 at 3:6 Comment(0)
P
1

Ok, in my case there was nothing in Problems view, what did help me is updating maven dependencies (right click on the project > Maven > Update project), I choose all the related projects and after that warning disappeared.

Plural answered 26/9, 2018 at 9:43 Comment(0)
G
-2

Go to Window → Show View → general → Problems and you will see the list of errors. In my case, some of the JAR files were missing on the build path. Configuring Build Path solved the "Error exists in your project" issue. In the 'problems' view, right click on the error and quick fix.

Guthrie answered 26/4, 2017 at 4:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.