Program Runs Differently When Executable Jar
Jan 27, 2014
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.
Why is that?
View Replies
ADVERTISEMENT
Aug 1, 2014
I was wondering if their is an easily explainable way to convert a jar for a text-based game that runs off the command prompt into a executable. I would guess there probably is not and the game would have to run off of completely different commands, but I thought it couldn't hurt to ask.
View Replies
View Related
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)?
View Replies
View Related
Jul 20, 2013
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()){
[Code] .....
View Replies
View Related
Apr 16, 2015
I have tried to get my dinky little program I wrote to be stored as an executable through Eclipse to no avail. It seems I have tried everything else as well, to no avail. I do not want it to go through command prompt, but rather have it be its own entity. As you can probably tell my knowledge of Java and coding is limited, but always willing to expand.
View Replies
View Related
Aug 8, 2014
I am trying to uses classes from a non executable jar called noexec.jar in an executable jar called exec.jar. With no defined manifest in the nonexec jar and a manifest in the exec jar. The folder structure where the jars are held look like so.
ROOT
/lib
|
---nonexec.jar
---exec.jar
With the class path defined in the manifest for the executable jar as Class-Path: nonexec.jar . However every time I run java -jar exec.jar, I get Exception in thread "main" java.lang.NoClassDefFoundError: What even though I am including nonexec in my class path why the classes contained within the jar are not being found?
This is the manifest file
Manifest-Version: 1.0
Class-Path: nonexec.jar .
Main-Class: start
View Replies
View Related
Feb 25, 2014
My current URL is URL....The context rootpath is URL....In my current URL page, I upload a CSV file. This page has two buttons-- ok and Cancel and these buttons are what I'm having trouble with ( I will come to that part in a short while). The relevant JSP part is as follows.
<html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data">
....... some headers and title bar and stuff... and then as follows.
<div class="contentSection">
<table border="0" class="formTable">
<html:hidden property = "selectedSet" />
<tr>
[code]...
So, if I click on cancel in the second URLpage (URL...), I go back to the first URLpage, i.e to URL...But this part behaves differently in Firefox and in Chrome browsers.In Chrome, if I click on cancel in the second page, I can still see the uploaded file name( the hidden property in the first JSP is the file name ) in the first page. And if I click on ok, I can do the processing again as was done by clicking ok the first time on the first page.However when I run my application in a Firefox browser, if I click on cancel in the second page, the uploaded file name says 'no file selected' in the first page. Hence to import Employees again, I need to upload a new/same CSV file again.
I don't want the file to be present in the first page when I click on cancel in the second page even when I run my application in Chrome. Yes, I require the file name to be a hidden property. This is because depending on the data in the file, different kind of processings are done and some of them require to take additional inputs from user on another page and a third page does the processing. So the file name should be passed on to the form but I don't want the user to upload the file again.
However in the event the user clicks on cancel, I don't want the file name to be retained in the first page. But this isn't happening.So I have two questions. Why is the behaviour different in Chrome and in Firefox and is there a way I can correct the way it behaves in chrome?
View Replies
View Related
Apr 26, 2015
Here is my code. Obviously this doesn't do a lot but that's only because I abstracted out the problem so there are not many lines to decipher.
Java Code:
import java.util.Scanner;
class threadOne extends threadTwo {
public static void main(String[] args) {
threadTwo threadTwoObj = new threadTwo();
threadTwoObj.start();
while (!userInput.equals("exit")) {
[Code] ....
What its supposed to do: When the user returns "exit" in the console it is supposed to break out of both while loops in both threads.
What it actually does: breaks out of the while loop in threadOne and not in threadTwo.
Basically the idea is to have a thread running doing computation and another thread able to query it for updates or interact to make changes to the flow. This will be useful, among other ways, for the sorts of problems where finding a solution is easy but where a better solution can always be found with more time. So for example finding directions on a map. Its easy to find a solution, but if you search longer you can find a faster route, if you search longer still than faster still.
View Replies
View Related
Mar 16, 2015
I have an ArrayList, based on the class which stores cricket players, their names and runs scored.When I use the Collections.sort() method my arraylist is sorted alphabetically by forename.how to OverRide the comparing method to sort by runs, and thus the code I use to sort the list?
View Replies
View Related
Apr 27, 2014
I'm using the book "How to Program in Java 9th Edition". The following is code from that book. I'm using eclipse. When the code is run the images are not showing up in the frame. The images are located in the directory with the java file and I have tried using the fully qualified image locations with no success. I've looked around on the web but can't see any reason why this code won't work. The code compiles and no errors are reported.
// Fig. 9.13: LabelDemo.java
// Demonstrates the use of labels
package Fig9_13DisplayTextImagesWithLabels;
import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JFrame;
public class LabelDemo
[code]....
View Replies
View Related
Jan 4, 2015
How do I record the number of times all runs of heads occur. Ex.
Length Number of runs of heads
1 --------------------3
2 --------------------2
3 --------------------0
4 --------------------1
public static void main(String[] args)
{
int [] coinToss = new int[TOSSES];
int longestRun = 0;
int run = 0;
for(int i = 0; i < coinToss.length; i++)
coinToss[i] = toss();
[Code] .....
View Replies
View Related
Jan 12, 2012
I have a single class application which works well in the Eclipse console. But how do I turn it into a Jar file?
View Replies
View Related
Nov 17, 2014
I'm trying to do a user validation loop that runs until the user enters a valid binary, q, or Q. I think the rest of my program should work as intended, but here is the areas of concern:
public static boolean isBinary(String num) //Check if the entry is binary
{
for(int i = 0; i < num.length(); i++) {
if(num.charAt(i) != 0 || num.charAt(i) != 1){
return false;
[Code] .....
The program runs without errors otherwise.
View Replies
View Related
Mar 24, 2014
So I have a class called Team that is a collection of players and managers for a baseball team, and one of my required methods is to calculate the total amount of Home Runs hit by the batters. Now along with the Team class I have an abstract Employee class, an abstract Player class and a Batter class that extends the Player class I thought this would be fairly easy but it is coming out to be pretty hard my code is as follow:
class Team {
public int _numPitcher;
public int _numBatter;
public String _manager;
public ArrayList<Player> team;
[Code] ....
The total salary works awesome but for some reason when I try and call up how many home runs a player has it wont call correctly I get this red line under my code that says: The method getHomeRuns() is undefined for type Player. I am trying to call this from the batter class which is an extension of the Player class...
View Replies
View Related
Jun 23, 2014
I tried using ScheduledService but the delay and period fields accepts a Duration object. I want the Service to run at exactly 6.00 pm everyday.
View Replies
View Related
Aug 8, 2014
I am working on a card game and for lack of better terms, have royally screwed up my files. I do still have an executable jar that I would like to go back to if possible and try to redo what I messed up. What I was able to do was to use WinRAR and get ?encrypted? class files. Something that is obviously not editable. How can I go about converting these back to editable java files, if possible?
View Replies
View Related
Nov 21, 2014
So let's say i have an executable jar and inside that jar is a bunch of files. How do I access files within my jar?
Assuming like, a main class is currently running and that is what's inside the manifest file as the main class inside that executable jar..
View Replies
View Related
Nov 8, 2014
I am new to JAVA. I need to execute a program, based on the OS. If I am on Mac, the program is a .x and if It is on Windows the program is .exe. The program also requires a line of commands attached to it (i.e. relap5.(x) or (exe) -i inputFile -o outputFile -r restartFile -s stripFile
Here is my coding
String in = " -i ", tfIntdta.getText();
String rst = " -r ", tfRstplt.getText();
String out = " -o ", tfOutdta.getText();
String strp = " -s ", tfStpdta.getText();
if tfStpdta.contains(".csv")
String run = in, rst, out, strp;
else
String run = in. rst, out;
// I want to execute either a .x file or .exe file, depending on if I am
// running the app on windows or mac
run relap5.(x) or (exe) (string run goes here)
View Replies
View Related
Apr 15, 2015
I made a project in eclipse and exported it with libraries into a jar file.
Now I need to obfuscate that jar file so it can't be reverse engineered or anything.
I just need something basic. Just where I put the jar file as input and it will output another jar file that is obfuscated.
I looked at proguard but it looks complex for something like this. I don't want to be spending ages making config files or anything... What I should use?
View Replies
View Related
Dec 25, 2014
when I am programming let say in VB using Visual Studio, finally I build .exe file that can be run on all Windows by double click.For Java I am using Eclipse and to run those apps I am using run from Eclipse.How I can create a sort of "executable" for my Java app that I would be able to run it by file click on Windows or Linux?
View Replies
View Related
Feb 20, 2014
Embedding an executable .jar file on a webpage. I am not a programmer and we use Blackboard Publish to package our Blackboard sessions into a standalone executable .JAR file which gives the user the full Blackboard experience. We want to embed this file on our webpage, so I did some research and I understand I have to use a Japplet (?). I have tried putting the basic (J)applet code I found on the web (modified of course) onto the webpage (see code below) but I get a 'ClassNotFoundException' error. I don't have the ability to define the files that are in the .JAR created by Blackboard Publish. How I would go about embedding this file? I can look at the files within the .jar with Winzip but there seem to be loads of .class files and I am unclear which one my webpage is trying to find!
<APPLET CODEBASE="/Blackboard/" ARCHIVE="test.jar" CODE=test.class WIDTH=140 HEIGHT=45>
<(J)APPLET>
View Replies
View Related
Aug 7, 2014
how run the executable jar files using JButton from another class file.I need, when i click the button then the executable jar file should be and display the output.
View Replies
View Related
Feb 11, 2015
I have an executable jar file that I decompile using androchef. I have to use androchef otherwise I get to many errors especially with jd-gui. I need to know how to export the files after I have decompiled them with androchef so that I can edit a file then send to netbeans and rejar.
View Replies
View Related
Oct 25, 2013
I am wondering if there is an easy way to create a java exe(cutable) binary, by packing the JRE and ship it like a compiled C++ bin file? I know JAR is good but, I still prefer to create a standalone install - free exe, no matter if the user has or has not Java installed on her PC.
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
Jun 18, 2014
I have one Project -"A".Inside of that I use, .XLS to read data.
Structure - A/src/TestData
Inside of the TesetData - I have placed XLS files.
I have main method in TestDriver class.If I run this in Eclipse, running fine.But after exported to executable/runnable Jar, and ran via command line (command - jar -jar myjar.jar), I see issue: "Exception in thread "main" java.io.FileNotFoundException: srcTestDataTestCaseController.xls"
public static void main(String[] args)
throws Exception
{
ResultSet rs;
rs = readExcelData(testControllerName, sheetName, "");
}
As I use main() method which is static, I am getting error if I write like the below:
public void getXls(){
String testControllerName ="TestCaseController.xls"
TestDriver.getClass().getClassLoader().getResource (testControllerName);
}
How to read/access the XLS, after I exported as runnable jar
View Replies
View Related