Exporting A Java Program From Eclipse That Only Runs In Console
Oct 11, 2014
I have recently revisited a program I wrote a few years ago, that runs absolutely fine in the console in Eclipse. However, when I export it as a Runnable Jar File, then open the file on my Desktop, nothing happens.How do I get the program to export so that when I open the file, a window opens that acts as the console (so the program can run in it)?
I'm new to java programming and I've been trying to make my first program in eclipse for a while, and I finally managed to do that. Well my problem is that I want to be able to use my program without having to open eclipse and opening my program from there, is there any way to do that ?
im wanting to create a console gui that opens with my program game and people can type stuff in it to run commands as well as a debug option to show when errors happen and have a command to list all availble command.
i have programmed a game using JPanel and JFrame. My App is of this type (if this is relevant to the problem):
public class Main extends JPanel { private JFrame frame; public static void main(String[] args) { new Main(); } public Main() { frame.setSize(WIDTH, HEIGHT);
[Code] ....
The problem is, When i export the file in eclipse as Runnable jar file,and run the exported file, it gives me a blank screen (white default) and nothing is running. Whereas, normal debugging of the game is working quite well.
So I am trying to write the output of two different java class files to one txt file while the program runs. The file name is determined before the program is ran, through the command prompt as arguments. How can I get the second class file to edit the same txt file without running into compile errors.
For right now I'm just going to send everything that the second file outputs to a message String variable, so that the Main class outputs to the the text file. I still want to learn how to write to the same text file directly from the second class file.
import java.io.*; public class Test{ public static void main(String[] args) throws IOException{ int x; //create a new file internally called doc. But externally labelled the user input File doc = new File(args[0]); if (doc.exists()){
Follow the //? FIRST and SECOND notes, then I understood that Java has GOTO as Keyword for future versions and that usually one can avoid GOTO using break inside the cycles, but I need a jump( salto) in the code.
import java.util.Scanner; public class ArrayOrdinati { public static void main (String[] args){ int[] Array = {5,3,1}; int e=Array.length; int b;
I took an example from here on client server sockets: Complete Java Networking Explained with Simple Examples - Go4Expert and placed it in separate classes and had a single main to run it both a server then the client.It seems ok but I cannot have the console outputs sharing the same console.
I start the server first and this takes precedence and the client will not output to console unless I stop the restart the app after commenting out the server startup as its already running, then eclipse gives me 2 consoles I can move between Is it possible to have both client and server share output console?
Basic console java program. I need to generate an employee id. I have an employee class that I will paste here so you can see my fields and constructors.
public class Employee { private String firstName; private String lastName; private int id; public int nextUniqueId = 0; public Scanner sc = new Scanner(System.in);
I am struggling getting my java app to open a console window on either MacOS or windows and run a command. On windows I can get the cmd.exe program to open, but it won't execute the command. On MacOS, I cannot get it to even open the terminal.
String run = "c: s34bil.exe elap5.exe" + in + rst + out; //in, rst, out are parameters for the relpa5.exe file. try { Runtime rt = Runtime.getRuntime(); rt.exec(new String[]{"cmd.exe","/c",run,"start"}); } catch (IOException ex) { Logger.getLogger(issrsUI.class.getName()).log(Level.SEVERE, null, ex); }
I have a little application that I made, it requires that I save data to a file in data/coins.cdp. When I run the application with java myProg in the terminal everything is correct, when I create the executable jar and run java -jar myJar.jar or ./myjar.jar everything also works. Even if I copy the jar to a different location, and run it through the terminal, it still works fine. Things get weird through when I copy the jar to a new location and double click on it, because then no folder gets created and no file is written.
I've made a simple program in Java (Eclipse) that converts Fahrenheit to Celsius.The class is:
Java Code: package ehu.student; public class ConversorTemperaturas { /*--------------------------------------------------------------*/ /*Clase que dado una temperatura en Fahrenheit la canvierte en C*/ /*--------------------------------------------------------------*/ public float farenheit2celsius (float d){ float celsius, aux;
[code]...
When I write t.farenheit2celsius(25.6), appears the following error: "The method farenheit2celsisus(float) in the type ConversorTemperaturas is not applicable for the arguments (double)"If i change in the class the type float for double there is not problem. Why can't i use the type float?
I tried to run the program in eclipse(See Attachments 2 3 4) but I got the following errors(Attach 1), I have attached them as screen shots.
1.Errors
2. Mapper code
3. Reducer code
4. Driver
Since am new to java and hadoop, I want to know the procedure step by step in a brief manner.run this program and rest of the two statements successfully.
how to put a console on a JFrame or on graphics window. I thought about simply using a JtextField however I don't have access to the readline command since it appears to me that it is only found in a Console Program. So basically I was wondering how to put up a console on JFrame so I can issue commands on it and watch graphical stuff happen on the same screen(minus where the console box is of course).
My task is to create multiuser console chat program. During whole day of poking around , i finally stand on such concept:
1. When running , Server part must stay into while(true) loop and create threads on each ServerSocket.accept() call, providing socket object inside thread. i.e.
while (true){ System.out.println("Waiting for client to connect"); Thread t = new Thread(new Runner(servSocket.accept(),listOfClientSockets)); System.out.println("Starting thread"); t.start(); }
2. Client side always stays within while(true) loop and waiting for user input with ScannerInstance.nextLine() method. As soon as user prints something and hits enter, data being captured from scanner and thrown to socket output stream to the server.
My question is : if all parties (X clients and server) are actually in waiting mode (server is waiting for connections and each client is waiting for user input), who will refresh the screen for each client to draw the messages other parties sent?
At this time , each party see updates only when he hits enter and while loop does next iteration reading data from buffer and displaying on console.
I'm writing a command line application of a calculator in Java. I need to be able to (as per program requirements) split the array of strings (6+3) into an array of strings? How would that be done? I know you can use the split method, but I am not really sure how that wold work to perform math with them?
On a side note: for this application, how could you make the program accept a variety of different lengths of strings to perform math with them?
While making my holiday program and trying to use the Jansi library to add color to the console text,
I got this output:
Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - package org.fusesource.jansi does not exist at Main.<clinit>
I've been provided a code skeleton for what must be done, but despite my best efforts to make things work, I'm coming up dry (obviously, due to a lack of knowledge.) One thing that might work is if I knew how to debug this type of application, line-by-line, to see exactly what is going on. Obviously, it's easy enough to debug the client part, but moving over to the server part, I haven't been able to figure that out (I'm using Eclipse.)
I've got a Java application made in eclipse using lwjgl. I'm trying to make a working exe-file by the following steps:
- Export project as executable jar (copy libs into subfolders) - Making a fat jar using jarsplice (adding lwjgl-jars and natives) - Wrap the fat jar in an exe-file using launch4j
Result: Error: invalid or corrupt jarfile.
The fat jar is working fine. If I make an exe-file directly in jarsplice it also works fine but then I'm missing the possibilities of setting the icon etc.
This is what I do in launch4j:
- Choose an outputfile (ending with name.exe) - Choosing the fat jar - Specifying min JRE version to 1.7.0 (says JavaSE-1.7 in eclipse) - Build wrapper - Run -> Error (see above)
I seem to be having a issue with my java console app what it should do is query a SQL DB and list the user details (userid, firstname ,lastname) from the user table, and the users stocks (stockname ,stockdiscription) associated to each user from the userstocks table if I'm thinking correctly!
I'm sure it is just a logical error, but I'm not sure of the way to get the out put I'm looking for. I will add the makeDB.java file and DatabaseQuery.java file as well as the current Exception(Run Time Exception) below.
**I have added other users and stocks manually - Not just what the MakeDB.java file inserts **
Output and Exception:
Stock holdings by User User ID User Name Stock - Description ------------------------------------------- admin01 Default Admin Exception in thread "main" java.sql.SQLException: ResultSet is closed at sun.jdbc.odbc.JdbcOdbcResultSet.checkOpen(JdbcOdbcResultSet.java:6647 ) at sun.jdbc.odbc.JdbcOdbcResultSet.next(JdbcOdbcResultSet.java:1248) at DatabaseQuery.main(DatabaseQuery.java:45) Press any key to continue . . .
Java Code:
MakeDB.java: import java.sql.*; import java.io.*; public class MakeDB { public static void main(String[]args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");