Running Out Of File Descriptors
Nov 6, 2014
We've got a java web app (running on a Solaris machine with Weblogic) and from time to time it stops working due to this error:
Java Code: java.net.SocketException: Too many open files mh_sh_highlight_all('java');
For what I've read we are somehow exceeding the established limit of file descriptors, and it seems that this may be caused for many reasons, not only open files that we forgot to close.
I am making a list of everything that may consume a file descriptor in the system mentioned above, so I can start reanalyzing the app... if needed, as I don't know if we're wasting them or if the limit is just insufficient.
View Replies
ADVERTISEMENT
Oct 28, 2014
I have a TxT file with the next content:
[Cars]
BMW=3
Lamborghini=10
[Computers]
Mouse=5
Keyboard=12
How can i read the file and output in
System.out.println("Category " + descriptor + " Value: " + )
The output console should look like :
Cars : Lamborghini 10
BMW 3
Computers: Mouse 5
Keyboard 12
And the Value MUST be readed from thext file for each descriptor.
package test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Map;
public class Descriptor {
private final String descriptor;
[Code] ....
View Replies
View Related
Jun 11, 2014
I just wrote a java program with eclipse that has to read many-many inputs from the user. I want to test it, but I really don't want to type it everytime again and again...
Can I just write all inputs in a text file and let eclipse read this file so instead of typing it again and again, Eclipse reads every line whenever it waits for a user input?
View Replies
View Related
May 19, 2014
This is my program: RemoteXMLRead.java
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.apache.commons.io.filefilter.WildcardFileFilte r;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
[code]....
It is working fine when i run in Eclipse, but is giving error when i run in cmd.. What i need to do to over come this..
View Replies
View Related
Apr 16, 2015
I am working on a management gui for a program. I have implemented the start server button. But now I need to get something working so that when I press stop server the javaw.exe process which is running the the other jar file is stopped and ended.
The gui is going to be using a javaw.exe as well and I don't want to end the entire thing.
I just want to end the javaw.exe process that is running the other jar file.
This is my code for starting it:
JButton btnNewButton_2 = new JButton("Start Server");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("java -jar DEDServer_release.jar");
[Code] ....
I just need to figure out what to do to stop it now.
View Replies
View Related
Apr 24, 2014
import acm.util.* ;
import acm.program.*;
import java.awt.* ;
class Chap6_ex1 extends ConsoleProgram {
public void run() {
println("This program displays a randomly schosen card.");
int number = rgen.nextInt(1 ,13);
int suit = rgen.nextInt(1 ,4);
[Code] ....
I am running the this from a Linux command line , in the cmd first i use :
javac -classpath acm.jar Chap6_ex1.java
end then :
java -cp .:acm.jar Chap6_ex1
The output i m getting after second command is :
Exception in thread "main" acm.util.ErrorException: Cannot determine the main class.
at acm.program.Program.main(Program.java:1358)
I know the problem is from the RandomGenerator class in packet acm.util.* but i dont know how to fix the problem . Every other program has worked . What I am missing or how this whole issue of packet importing works when running a java file from cmd ?
View Replies
View Related
May 22, 2014
I'm running a jar of an application and library jars from lwjgl. I'm creating a java process. It's working on Windows but not on linux.
I tried replacing the semicolons with colons but it didn't work, it just said "Main class not found: Application.natives.linux" or something like that. gamePath is the path the application is in. osName is the name of the operating system.
Here's my code:
String jarRunner = String.format("java -Djava.library.path="%snatives/" + osName + "" -cp "%sjar/lwjgl.jar;%sjar/lwjgl_util.jar;%sjar/jinput.jar;%sjar/slick.jar;%sApplication.jar" main.Main", gamePath, gamePath, gamePath, gamePath, gamePath, gamePath);
Process p = Runtime.getRuntime().exec(jarRunner);
[Code] ....
How can I make it work on linux?
View Replies
View Related
Oct 14, 2014
So this is probably pretty simple but I can't seem to figure it out. My teacher wants us to write a code that scans a text file, then outputs some text based information AND displays an applet bar graph of the data sorta like this for the text:
Sample Bar Graph
1-10 |*****
11-20 |******
21-30 |**
31-40 |*
41-50 |***********
51-60 |******
61-70 |********
71-80 |***
81-90 |****
91-100 |****
and then an applet thats the same info just a little more graphic. My code interprets the input well, but when i try to make an applet output, the code basically forgets all of my variables and starts anew (when i just state the public static graphic (paint) class after everything) OR it refuses to scan the input file (if i switch the public class from main.....throw ExceptionIO to just public class graphic(paint))
Also, as a side note, any way to have java automatically determine how many separate lines there are in a text file without me having to manually count them.
import java.util.Scanner;
import javax.swing.JApplet;
import java.awt.*;
import java.io.*;
public class Project2 extends JApplet {
[Code] ....
View Replies
View Related
Jul 10, 2014
I'm trying to run a command line executable file using java but there is no output. On the task manager a conhost process opens when the application is run. I've tried
1)try {
Runtime.getRuntime().exec("D: est.exe");
} catch (Exception e) {
e.printStackTrace();
}
2)String[] cmd = { "D: est.exe"};
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
and
3)//Runtime.getRuntime().exec("D: est.exe", null, new File("D:"));
same thing happens i.e. nothing happens.
View Replies
View Related
Feb 27, 2014
I have a program that is a XML-parser, and it works fine when I'm running it from NetBeans. But when I create a JAR-file and run the very same program, it cannot find the xml file. Consider this small program that addresses my problem:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
[Code] .....
View Replies
View Related
Nov 27, 2013
I have followed the Java tutorial on JAAS Authentication and Authorization. All the sample code in the tutorials works fine also when running under a security manager. Now I am trying to modify the LoginModule class, so that it uses a password file to look up users and passwords, but as soon as I try to run the code under a security manager, I get a Security Exception. I suppose it has something to do with the code havent been granted any access to read the password file? So I tried to add this to the policy file:
grant codebase "file:./sample/module/-" {
permission java.io.FilePermission "sample/module/passwords.txt", "read";
};
It didn't do any difference. why I get this Security Exception?
The only difference from my code to the tutorial code, is that I have added the lines:
Scanner scanner = null;
try {
scanner = new Scanner(new File("src/sample/module/passwords.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
to the login() method of the SampleLoginModule class...
View Replies
View Related
May 3, 2015
This is a program that prompts a menu using the do-while iteration. If user input is not valid, the menu should be reprompted once. But when I run the code and enter an invalid value, the menu is prompted 3 times.
class Menu {
public static void main(String args[])
throws java.io.IOException {
char choice;
do {
[code]....
View Replies
View Related
Feb 17, 2014
I have a directories in UNIX:
/home/t_bmf/Java/HelloWorld/src/helloworld :will contain a .java file
/home/t_bmf/Java/HelloWorld/bin :will contain all .class file
Let say a have a code:
package helloworld;
public class HelloWorld {
public static void main(String[] arg) {
System.out.println("Hello World");
}
}
a command to compile this even outside the directory /home/t_bmf/Java/HelloWorld/src/helloworld
javac -d /home/t_bmf/Java/HelloWorld/bin /home/t_bmf/Java/HelloWorld/src/helloworld/HelloWorld.java
This will generate a directory /home/t_bmf/Java/HelloWorld/bin/helloworld and file inside this is HelloWorld.class
To run this program I must be in directory /home/t_bmf/Java/HelloWorld/bin and using this command:
java helloworld.HelloWorld
Question:
I already how to run the HelloWorld.class, but I must be in helloworld /home/t_bmf/Java/HelloWorld/bin to run it. Is there's a way to run the class even when I am not in directory /home/t_bmf/Java/HelloWorld/bin? Let's say I'm in /home/t_bmf, can I still run the HelloWorld.class?
View Replies
View Related
Jun 11, 2014
I've got a problem with my home made game. When I created it as a JFrame application it runs smoothly, but when I tried to convert it to a JApplet the graphic is "lagging". I can see the graphics blinking/flashing .....
Here is the code:
public class FallingBalls extends JApplet implements KeyListener,
ActionListener {
// VARIABLES //
boolean gameOver;
boolean win;
// Buttons
JButton start, pause, restart;
// Character "The Runner" (32px x 32 px)
[code]....
View Replies
View Related
Nov 23, 2014
I'm getting back into the swing of things with Java after using I'm asked to utilize a simple GUI in order to take in the starting data, I cannot seem to get this to work. I'm getting this error Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at Input.buildPanel(Input.java:53)
at Input.<init>(Input.java:27)
at InputDemo.main(InputDemo.java:5)
I've created two classes
import javax.swing.*;
public class Input extends JFrame {
private JPanel panel;
private JLabel messageLabel;
private JLabel messageLabel1;
private JLabel messageLabel2;
private JTextField shiftHrs;
[code]....
View Replies
View Related
Apr 1, 2014
I have a problem with running my hello world aplication. Here is the code.
public class HelloWorld {
public static void mаin(String[] args) {
System.out.println("Hello world!");
}
}
It compiles fine. But I get an exception when I try to run it.Here is the error message I'm getting:
Exception in thread "main" java.lang.NoSuchMethodException: HelloWorld.main([Ljava.lang.String;)
at java.lang.Class.getMethod(Class.java:1605)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Process finished with exit code 1
View Replies
View Related
Mar 30, 2014
I've been playing around with this for about an hour.
Java Code:
Runtime runTime = Runtime.getRuntime();
try {
Process process = runTime.exec("notepad");
} catch (IOException e) {
e.printStackTrace();
} mh_sh_highlight_all('java');
So that works. Notepad will open.
However, I'm trying to get other programs to open. Specifically, this program: C:Octave3.2.4_gcc-4.4.0inoctave-3.2.4.exe...However, using that in place of notepad doesn't work. I'm assuming that there is some sort of system variable that explains why simply typing "notepad" works? As if you type notepad into the run box, notepad will open. Soo does that snippet work by going through some sort of system variables?How would I go about opening other programs, such as the one I referenced above.
View Replies
View Related
Jun 8, 2014
Tried to run ServiceServerImpl.class with rmic and got this error. Below is the command prompt text pasting.
"C:Program FilesJavajdk1.7.0_21in>rmic.exe ServiceServerImpl
error: File .ServiceServerImpl.class does not contain type ServiceServerImpl as expected, but type serviceserver.ServiceServerImpl. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
error: Class ServiceServerImpl not found.
2 errors "
Here is the source code of the class file. Using Windows 8. I copied the .class file to the rmic.exe 's location later. didn't work either way. It is in a package called "serviceserver"
package serviceserver;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
public class ServiceServerImpl extends UnicastRemoteObject implements ServiceServer
{
HashMap serviceList;
[Code] ....
View Replies
View Related
Feb 11, 2014
i have a program in UNIX directory /home/me/java/src
package bin;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
I have manage to compile it successfully(class file will be in bin directory) using command below: javac -d /home/t_bmf/java/bin HelloWorld.java
My problem now is how would I execute the class in bin directory in UNIX? I already tried different ways on how to execute it as suggested in my internet research The one I tried is this:
java $CLASSPATH:.:bin/HelloWorld
but I got this error message:
Exception in thread "main" java.lang.NoClassDefFoundError: :/:bin/HelloWorld
Caused by: java.lang.ClassNotFoundException: :.:bin.HelloWorld
[code]....
View Replies
View Related
Feb 15, 2014
The while loop keeps running although I type quit. What is wrong with this code?
import java.util.*;
public class OddEvenGame {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
Random r = new Random();
]Code] ....
View Replies
View Related
Feb 24, 2015
The below method shows that a JOptionPane should display when the result is null, meaning it has not found what I was trying to look for. However only the if statement that finds the query runs:
public void find(Person person) {
String query = "SELECT * from employee WHERE last LIKE'" + lastName
+ "'";
try {
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
[Code] ....
View Replies
View Related
Apr 30, 2014
When i run a applet file in browser(IE, Chrome, Firefox) it gives a error of security risk and block the application from running. All browser are giving same error. Programme is running correctly in Myeclipse
View Replies
View Related
Dec 14, 2014
I've just installed the last Java kit JDK plus netbeans and I've done my first project in Java. It is running perfect from command line<but is is difficult to execute each time from there my tests> but I couldn't run the jar file from windows with double click he jar file even I've spent 3 hour on google to find different methods (registry modifying, control panel/program running in windows, a patch file etc, ) ....
View Replies
View Related
Feb 3, 2015
I keep getting the error Admit.java:10 cannot find symbol
import java.util.*;
public class Admit {
public static void main(String[] args) {
sayIntro();
Scanner console = new Scanner(System.in);
System.out.println("Information for applicant #1:");
getScore(console);
getGPA(console);
[Code] ....
The compiler then reads:
Admit.java:10: error: cannot find symbol
score1(ACTScore, SATScore, GPAScore);
^
symbol: variable ACTScore
location: class Admit
Admit.java:10: error: cannot find symbol
[Code] .....
10 errors
View Replies
View Related
Nov 12, 2014
I have built a Java app that uses SQLite (sqlite-jdbc-3.8.7.jar). Running the jar file on windows works as expected however, trying to run it on Ubuntu Server 14.04 has turned into quite a task!
I put together a brand new machine in VirtualBox for testing. I installed Java (sudo apt-get install default-jre) and have installed SQLite (sudo apt-get install cl-sql-sqlite3 sqlitebrowser). I created a new sub-directory within my home directory and copied over the jar file. From terminal, I then run the command: sudo java -jar ProductionView.jar and I receive a java.lang.unsatisfiedlinkerror. For troubleshooting, within the app, before making a connection to the db, I have printed out the location of where the db is to be created and it is correct (see attached pic). Is there more that needs to be configured before I can run this app on Ubuntu? I have posted the relevant code below :
(AppDatabasePath() is what is printed in the image...).
public static String AppDatabasePath() {
return AppPath() + APP_NAME + ".db";
}
public static String AppDatabase() {
return "jdbc:sqlite:" + AppDatabasePath();
[Code] .....
View Replies
View Related
Mar 10, 2014
I am looking to run Server and Client from two different JButton.
When I click on start Server button, the server starts to run but I cannot click on start Client button to start the client. Here the code for server:
Java Code:
public void actionPerformed(ActionEvent e) {
Client c = new Client();
c.run();
} mh_sh_highlight_all('java');
View Replies
View Related