Moving Executable Jar Breaks App Save Function

Apr 1, 2014

I've been trying to deploy my desktop application as an executable jar file but I'm facing the following problem: Whenever I move the jar file from its original build location, my application becomes unable to write to its external files. I initially thought the problem was path related; however, when moved the app can still load data from these files.
 
The solution is probably simple but for some reasons I've yet to find it .
 
The app consists of a jar file and a folder named "files" containing text files (such as library.data) to which serialized objects are written.
 
I wouldn't be surprise if the problem has to do with the xml build file, but all modification I've tried so far have failed. If it is likely that it is the problem, I'll be happy to post a copy of it upon request.
 
public static void saveLibraryToFile() {
    File file = new File(System.getProperty("user.dir")+"fileslibrary.data");
    if (file != null && file.exists()) {
        library = new Library(sortedAccounts, accountCategoriesMap, accountCategoriesList);
 
[Code] ....
 
A mostly complete set of the relevant codes I'm using, including the full Ant xml file, can be found at : [URL] .....

View Replies


ADVERTISEMENT

Private Var Won't Save Value Of Public Getter Function From Base C

Sep 15, 2014

I'm working on this program for a class to create objects of a commissioned employee and union employee. Everything seems to work ok, but when I run my final pay calculation, one of my getter functions will not pass the variable for the pay into a class specific variable called check. here is the code in this function.

public void finalPayCal_U() {
setweekPay();//calculates weeks pay under 40 hours, stored in getweekpay
check = getweekPay();
if(getHours() > 40){
check = check + (1.5 * (getHours() - 40) * getRateOfPay());
}
check =- Dues;
}
}

The issue lies in check = getweekPay();

I thought this was a legal move, but I can't get it to work. It doesn't come back with anything more than 0 any time I run it.

All of these functions are out of the base class, employee (this function itself lives in the derived union class)

public void setweekPay() {
if (hours <= 40) {
weekPay = hours * rateOfPay;
} else {
weekPay = 40 * rateOfPay;
}
}

When I run, this function works as it returns the value when i print it to test.

however, when I do the part that says check = getWeekPay() above, it doesn't change the check variable. The only thing I have on the check variable is the dues taken out of it at the end, so it ends up being a negative number.

I have a similar problem with the other derived class's check variable. Both classes have the same variable as private but one is check the other checkC.

View Replies View Related

Complicated ArrayList Function - Moving Between Fields Which A Player Can Perform Based On Game Rules

May 27, 2014

I have been working on this function and i can't get it to work. It's a little bit complicated so let me first explain what this is about:

1. As a little exam in my studies i have to program a halma console game with KI an stuff.

2. Everything is finished and works except for the Move-Calculation.

3. A Move is a Move from Field a to Field b which a player can perform in one round based on the game rules (Careful: We are not using the standard halma rules, we use different ones).

4. Class Move consists of the Starting Cell where the Figure before the Move stands and a target Cell where the figure will stay on at the Move end. It may include an Array of serveral Cells, the stop cells which the figure passes from start -> target since several jumps can be performed in one Move.

Valid Examples for Moves:

a -> b (From Field a to Field b)
d -> f through g,h,i (From Field d to Field f through the Field g,h,i

My Move Calculation where all possible Moves are calculated for a given figure consists of 2 parts. An expand() function which will generate all possible moves (works perfectly) and a jumpFix() function which isn't working properly.

Example:

After expand() I'm getting something like that:

a -> b
b -> c
c -> d
s -> t

This is however not finished, because the first 3 Moves are actually 1 Move. Because the player can Move from a -> d in one turn because those 3 are consecutive Move. The fixed Move would look like that:

a -> d through b,c

jumpFix() is also perfectly working for that situation, however there is one specific situation when it doesn't work. Let's say we have this situation.

a -> b
b -> c
c -> d
b -> e
e -> f
f -> g
s -> t

Then the only valid jumpFix() output would be:

a -> d through b,c
a -> g through b,e,f
s -> t

However i can not get it to work yet. Note: It definitely needs to be iterative, not rekursive else i would get an StackoverflowError.

This is my current Code of jumpFix():

Java Code:

/**
* Takes a look into all calculated moves and finds those which should be seen as one move, but are still considered to be more than one move (several jumps in one move)
*/

public static List<Move> jumpFix(List<Move> moves) {
Set<Move> result = new HashSet<Move>();
Set<Move> remove = new HashSet<Move>();
int lastSize = -1;
// repeat action until no moves could be merged
while (lastSize != remove.size()) {

[Code] ....

How to implement the special case where a Move splits into 2 or more branches and jumpFix() able to handle this case.

View Replies View Related

Java Servlet :: How To Force Browser To Open / Save / Save As File From Server

Sep 25, 2012

How to force browser to open/save/save as the file from server instead of browser cache.

I am creating a csv file through a pl/sql procedure and forwarding the link to user once user clicks on link he downloads the file, however if the same thing is repeated then browser returns the old cached file instead of new file generated on server.

View Replies View Related

Use Classes From Non-executable In Executable Jar

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

While Loops And Conditional Breaks?

Feb 12, 2015

public class dowhile2 {
public static void main(String[] args) {
int i = 1;
while(i <= 100){
System.out.println(i);
if(i == 50){
break;
}
i++;
}
}
}

I just want to know how to count this lines of codes. Because if I place for example i++ further up the code or the system.out.println a bit lower the result will be 1-49 or 2-50 and not the goal that is 1-50.

I want to know how to think and count. Why do i get 2345678.........50 and not 12345678........50 or 12345678.....49, thats the question.

View Replies View Related

Code Breaks After Upgrading To Java 8?

Jan 22, 2015

We recently upgraded to JDK 8. Since then, a section of code in a jsp file breaks. The code is this:

ArrayList all = new ArrayList();
final List tsd = timeSeriesBean.getTSData();
all.addAll(tsd); 
Collections.sort(all, new Comparator() {
public int compare(Object o1, Object o2) {
TSData t1 = (TSData)o1, t2 = (TSData)o2;
int res = t2.getDate().compareTo(t1.getDate());

[code]....

The error message is this:

An error occurred at line: 65 in the jsp file: /TS/VerifyImportTSData.jsp The type new Comparator(){} must implement the inherited abstract method Comparator.thenComparing(Function, Comparator)
 
64:
65: Collections.sort(all, new Comparator() {
66: public int compare(Object o1, Object o2) {
67: TSData t1 = (TSData)o1, t2 = (TSData)o2;
68: int res = t2.getDate().compareTo(t1.getDate());

just trying to maintain some old java code that I can support until it is rewritten.

View Replies View Related

JSF :: Page Content In OUTLOOK Body Not Getting Breaks

Jun 3, 2014

I have a requirement. I got a JSF page(parent page). When a button(say SEND EMAIL) is pressed, an email window (OUTLOOK) will be displayed as a popup. I have to populate whatever the text data of parent page as the body of the mail.

I am using mailto method : eg :

Here is my code:
==============
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest();
context.getExternalContext().redirect(String.format("mailto:"+mailTo+"?subject=" + subject +"&body=" + body + "&cc="+mailCc+""));

till here it is fine..

My problem is body part is not getting breaks. I have tried
, ,
, <br>, <br></br> etc.. what ever stuff i found in google..

E.g. my email body looks like below.. it consists of url link also.

====================================================
Hi,

This is to inform you etc... ,

Please follow this Hyperlink link to navigate to your page.. etc.

regards..

======================================================

View Replies View Related

How Boolean Finished Is Set To False And Breaks While Loop

Sep 11, 2014

I'm having trouble understanding how this loop is broken, I can't understand how the boolean finished is set to false and breaks the While loop.

public void run()
{
char answer;
boolean finished = false;
while(!finished)// when false loop is broken

[Code] ....

View Replies View Related

JSF :: Call Function Inside Other Function

Jun 23, 2014

I would use the return value of a function how parameter of other function..In java is:

// the call produce "YES"
SecondClassController.funcSecondClass(FirstClassController.funcFirstClass());

In my web page I need to do something like this:

[...]
<h:outputText value="#{secondClassController.funcSecondClass(#{firstClassController.funcFirstClass()})}" />
[...]
obtain:
javax.servlet.ServletException JBWEB006007: Failed to parse the expression
@Named
@SessionScoped
public class FirstClassController implements Serializable{
[...]

[code]....

View Replies View Related

Extracting From Executable Jar

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

How To Access A File Within Executable Jar

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

Using A Button To Run Executable With Arguments

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

Obfuscating Executable Jar File

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

How To Create A Sort Of Executable For Java App

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

Embedding Executable JAR File In A Webpage

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

How To Call Executable Jars Using Jbutton

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

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 View Related

Executable JAR File - Decompile Using Androchef?

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

Running Java Program As Executable

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

How To Create A Java Executable Binary

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

Running C Compiled Executable File In Java

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

XLS Resources Not Loaded After Created Executable JAR For Project

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

Convert Jar That Runs Off The Command Prompt Into Executable?

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

Making Executable From Simple Java Code

Feb 16, 2014

I am totally new to java. How to convert the below java code to an executable file?

var intInterval = 0
function importdata(){
filename = "C:1.txt";
AmiBroker1 = new ActiveXObject("Broker.Application" );
AmiBroker1.Import( 0, filename, "custom.format" );
AmiBroker1.RefreshAll();
}

It simply imports numerical data from 1.txt into an application amibroker. Also this import function has to be in a loop of 60 seconds.

View Replies View Related

Java Into Executable Jar Force Horizontal Scrollbar

Apr 14, 2015

I have made a simple h2 db viewer using jdbc and in eclipse it has a horizontal scrollbar so it works and displays correctly.

When I run the jar from cmd it works as it should but the results all go onto new lines so all formatting is lost and it looks.. ugly...

somehow make it so the console has a forced horizontal scrollbar but dunno how.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved