Exported Jar file behaving differently compared to within Eclipse - java

I am developing a java application which isnt too complex. It connects to a Lotus Notes database to extract an embedded attatchment from a notes database and downloads it to a specified directory, in my case ("C:\Batch Printer\" + attatchmentname). The application works perfectly when ran within eclipse and does the job i require it to, however, i am now at a point where i need to extract the file to a runnable JAR. When i do this and run it the program no longer downloads the file. Another aspect of the program involves printing a file, which seems to work fine. It is just the issue of downloading the file. Do i need to run the jar file with administrator privledges or something? has anyone else had an issue similar?
I figure you dont need to see any code as it is working correctly except on export.
Any help much appreciated.
Ross.

Related

Windows Defender flag some JSON output file from Trivy as Backdoor:PHP/Remoteshell.V

I'm working on a project where I parse some YAML configuration files in Java, then forge a command to send to a processbuilder which calls Trivy, performs the required scans and then print out two files, one in JSON and one in HTML.
With most of the config files it works great, but with one of them, multiple JSON output files are flagged as Backdoor:PHP/Remoteshell.V by Windows Defender, so it puts them in quarantine and it stops the execution of the rest of my program because the paths don't exist anymore.
Sadly, I can't share the exact Trivy call because it is done on private Docker images that require access, but I can share some of the flagged JSON files if needed.
I tried scanning it with other malware detection software such as Gridinsoft and Zemana, but they don't detect anything.
I'm using IntelliJ IDE for this project and running it with Quarkus on a Windows computer, but I execute the Java program on WSL on a 20.04 Ubuntu because Trivy can't run on Windows.
I hope someone can help me on this issue as it is blocking me on my project, obviously I could just manually exclude the project file from the scan, but this is not a viable long term solution.

Java opening files - works from Eclipse, doesn't work in runnable JAR/exe

I have some java code that I'm using to open a file:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + output.getAbsolutePath());
It works just fine when I execute it from Eclipse, however, when I export the project to a runnable JAR, the functionality stops working. I've tried various different options to open the file (Desktop.open, ProcessBuilder etc.) all with the same results (Eclipse OK, runnable JAR not).
This exact code previously worked when I exported it in the past (1.5 years ago). I believe that was with Java 1.6 and now we're on Java 1.7. Not sure if that's the reason though and I don't have the option to compile using previous versions of Java. Any ideas?
thanks for attempting to help. I figured out the answer which is quite simply that I'm an idiot :) Opening the file wasn't the problem, the file wasn't being written in the first place, and the reason it wasn't being written was quite simply because the code was set to write it into a nested folder structure which had not yet been created. I didn't even think of this because I assumed that any necessary folders specified in the output string would be created automatically. Doh!

Images exporting but not opening - java

I am working on a program for a hacking to for FNAF 1 & 2, and for some reason, when I run the program in eclipse, it works just fine, but when I export it, it refuses to run because it says the file is missing, and when I check the jar file, all of the files are there. So, why is this happening?
If you need a class file, Please let me know, normally, I would post it, but it seems like a classpath error I seem to be making.

Netbeans plugin works perfectly while debugging, but not working when the plugin is installed to the IDE

I am currently working on a Java plugin for Netbeans 6.9.1 using the Apache POI api for interfacing with Microsoft documents that has two functions, the first takes data from a properties text file and creates an excel spreadsheet(.xlsx) containing that data, and the second part takes text from a spreadsheet and adds it to a properties text file.
When I run the code in the debugger both of the functions work great. The files get created and edited as they are supposed to, but I ran into problems when I created the NBM from the project and installed the plugin. The import (from .xlsx to .txt) does not do change the contents of the text file. I have checked variables at various times in the code to make sure there's nothing wrong with them there and everything was as it should. The export (.txt to .xlsx) works fine in the plugin, so I'm not sure exactly what's going on. When I start the import it goes through the steps, but nothing ever gets changed or written to the final files.
I'm pretty new to Netbeans so I'm not sure if there is a major difference from debugger to the actual plugin that is affecting how the program acts. Any help
The problem was creating a temporary file to write to. In the debugger it wrote to the projects folder, whereas when it was installed as a plugin it was creating the temporary file in Program Files. Windows wasn't letting the program get at the file once it was created in that directory so I changed it to create the file in Local App Data instead.
$ System.getProperty("user.home") + "\\Local Settings\\Application Data"
Glad that it's finally working, wasted a lot of time on such a simple fix, hope this can help someone else in the future.

Signed Applet trying to copy .jar file from Server URL to local filesystem. Works, but .jar gets corrupted

I'm trying to write an applet that installs files to the users system for use with an local Java mapping utility. I have a jar file with the main method for my Java utility along with a couple of other files that are used with my local mapping utility.
I use the following method from the Apache commons File-IO: Documentation here
Everything seemingly works fine. The file is copied upon runnning the Applet (the user is prompted with a warning requesting the permissions) and everything seems fine at this point.
When the file is run, however, the .jar gets corrupted and I literally watch as the file size goes from 250 kB to 0 right after it is run.
What would cause such behavior? I try extracting the archive and looking at the contents...all my classes seem to be there. What would cause a .jar to "self destruct" like this?
Also, if I just download the file normally. It works fine. It only corrupts like this when I download from the signed applet.
Thanks in advance for any insight!

Categories