Controlsfx Notifications don't work in compiled jar - java

I'm working on some app with GUI using javafx and have one trouble.
Notifications from controlsfx library (org.controlsfx.control.Notifications) work well when I'm running Main class from ItelliJ IDEA, but don't work in compiled jar (I have compiled jar using 'Build artifacts'). Other functionality work as well.
Here is method from Controll class that should open pop-up window
public void zAxisMouseEntered(MouseEvent mouseEvent) {
Notifications notif1 = Notifications.create();
notif1.title("Warning message");
notif1.text("This configuration is slower than 'SPL on Z axis'");
notif1.hideAfter(Duration.seconds(3));
notif1.position(Pos.CENTER);
notif1.showWarning();
}
Can somebody help me with using this notifications when I'm running jar?
Thanks!

I have fixed this isue by printing info to console. The problem was that there weren't two needed folders in final jar archive (I think it's IDEA bug) so I putted in them manually. After that I had javafx exception and I added this code
notif1.owner(chart3);
before
notif1.showWarning();
to avoid it.

Related

Trouble running a Java.jar file with a Swing GUI on Android phone - Major.Minor Version 52.0 & Main Class Name Missing

Hello!
The goal I have is pretty simple: I want to create an executable .jar file which should be able to bring up a form (made using swing) and write the put-in information into a well structurized plain text file. Due to portability/mobility reasons I will have to run this on an Android phone.
Since Android unfortunately doesn't have native Java support and I am unable to code a real Android application myself, I tried to use a Java emulator. Unfortunately, it appears that a working Java Emulator is hard to find to begin with. JBED instantly crashes on my Medion X701. Netmite's Website, which also seems to offer a .jar to .apk converter, appears to be down. JBlend seems to have installed properly, but I do not know how to work with the program now that it presents me nothing but an empty screen with the caption "0 Java ME Application(s)". On the web, I could not find a proper manual. PhoneME's official website was Java.net, which is no longer active. But during my research, I could find an older Version of PhoneME which seems to be running well.
As a test, I created a simple jar file that shows a maximized JFrame. Unfortunately, it isn't able to run my simple executable Jar file on my phone. The main reason for that should be the aforementioned error, which implies that the interpreter there is probably Java version 1.7, since PhoneME's last release was in 2015. There are more error messages referring to an "unknown source", which I believe originate from the first error. I tried to recompile my jar file using Eclipse, by setting the Compiler compliance level to 1.7 and choosing the jre 1.7 before exporting my project. Unfortunately, this didn't change the error messages I got on PhoneME!
As my last attempt, I created a Startup.class file which does the very same thing as my jar file.
import javax.swing.*;
public class Startup {
public static void main(String[] args) {
JFrame fishForm = new JFrame("Questionnaire");
fishForm.setExtendedState(JFrame.MAXIMIZED_BOTH);
fishForm.setVisible(true);
}
}
I compiled it using the command prompt in order to make sure that it is indeed using java 1.7 as the target. This .class file, which ran fine on my computer, leads me into a different error: "Main class name missing.", followed by multiple lines of usage explaination. The command line PhoneME presents doesn't seem to allow me to post command operations myself, as pressing Enter on the virtual keyboard does nothing.
My Questions
Is it even possible to run a Java application on Android which relies on the GUI libraries of Swing, or am I wasting my time?
Is there a different, up-to-date Java emulator for Android which I could use? Or is there a working jar2apk converter somewhere out there?
If not, then there's probably a reason why Java emulators ceased to exist. Is there a much simpler solution for my initial problem which I am missing?
I'll await your ideas eagerly!

Business Objects 'bcm.jar' error when exporting Java app

I have been working on creating a simple Java desktop app using the RESTful API for Business Objects and have run into an issue. Whenever I run my app in Eclipse in works fine; whenever I export it as a 'Runnable Jar' and select the Library handling option 'Package required libraries into generated JAR' it works fine. However, whenever I try to export it using the Library handling option 'Extract required libraries into generated JAR' I get the following error after running the app:
java.lang.NoClassDefFoundError: Could not initialize class com.businessobjects.bcm.BCM
I have the 'bcm.jar' file added under a 'res' Source Folder and have it added to the Build Path. At one point I added all the JARs under the 'SAP BusinessObjects' java folder, and external folder, but it still throws the error. The problem stems from this line of code:
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userID, password, CMS, auth);
Would anyone know why I am getting said error? I really want to use the Extract option as it will improve performance as my app becomes larger. Any help resolving this issue would be greatly appreciated :)
EDIT: I would be happy to provide clarification or further detail upon request!
Seems this was introduced in SP04 and SAP has no intent of fixing it as the RESTful API wasn't designed to be used with Desktop apps.
Have you included the cryptojFIPS.jar? Leaving it out can cause the error.

How do I run a DropWizard / Jersey server locally without having to restart & repack to get asset file updates?

I'm working on the client side of a project that is using DropWizard. Unfortunately what I'm experiencing is that for me to make a change to assets I have to stop the server, package the assets with maven, and then rerun the server or the assets will not be updated.
I tried adding dropwizard-configurable-assets-bundle but I'm still seeing the same behavior. Here's the service after adding it:
Service.java
public void initialize(strap<ServiceConfiguration> strap) {
// Assets
strap.addBundle(new ConfiguredAssetsBundle(
"/dashboard/app/", "/dashboard/", "index.html"
));
// Redirect /dashboard to /dashboard/
strap.addBundle(new RedirectBundle(ImmutableMap.<String, String>builder()
.put("/dashboard", "/dashboard/").build()));
}
I'm currently running mvn package && java -jar target/pack.jar server config.yml. I tried using Eclipse but I was having to restart it manually and it wasn't repackaging for me so it was slowing things down even further.
This whole process is reaaaally slowing me down and I'm hoping it's just my ignorance to the world that is Java.
In my Intellij Idea, i am using JRebel plug-in for this purpose. JRebel also supports Eclipse.
If your assets are packaged under src/main/resources then they should just update automatically with Eclipse without a restart being required, so long as you're running the executable service main() from within the IDE.
You may need to check that your Maven plugin is set to "generate-resources" on changes but that is just the default setting so should be in place already.
What you're describing is definitely possible in Eclipse - I have personal experience of making resource changes (e.g. change and save an HTML asset) and then seeing an immediate update upon doing nothing more than a browser refresh.

Java Distribution Code vs Development Code

I have an application developed in Java that's almost ready for distribution. However, I have a problem switching from my development env to publishing env, and back to development. For instance, in Eclipse, if I just want to do a test run via the run button, I have to change the code so my JMenuItems show up.
In my development environment I had the following that worked well:
JMenuItem[] appItems = new JMenuItem[2];
appItems[0] = new JMenu("New");
appItems[0].setIcon(new ImageIcon(../POS_System/images/new_icon_sm.png")));
But, as I near deployment, to get this to work in the deployable JAR, I need to alter the code:
JMenuItem[] appItems = new JMenuItem[2];
appItems[0] = new JMenu("New");
appItems[0].setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/new_icon_sm.png")));
This is order to reach into the JAR and get the appropriate image.
I have a lot of these JMenuItems. I'd really like to be able to test the app via the run button in Eclipse, as well as create a JAR without changing the code.
Is there a simple way to do this? I thought the getResource method would still allow me to use the JMenus, JMenuItems etc, but they aren't available when I run the program from Eclipse. It seems silly that I would have to keep switching back and forth.
I appreciate any help here.
If you do not want to move your images into the src/ folder as you have suggested, then in Eclipse, you should update your Eclipse configuration under the Project Prooperties -> Java Build Path and add an additional source folder, this one pointing to where you keep your images. I believe this will fix it.

Could not find or load main class Swing Java

Error: Could not find or load main class jewelleryerpapplication.GUI.ERPMainMenu
Java Result: 1
Actually i am using Net Beans 7.1 and in that i am continuosly getting the same error but un able to get the solution for that even after installing the latest update for that. The solution which i got from some body that create new project and copy the source and library foldes in that Project from the previous which generate the above error. this solution works for me but i need some simpler solution for this problem.Lot of thanks in advance.
Don't Forget To Give UpVote It If It Helps.
Right click on project node, go to Set configuration, select the main class for your application. Then clean and build.
Even if this doesn't solve your problem, then delete the Netbeans cache by deleting the (index) folder
User\.netbeans\6.9\var\cache\index\
I think that the following is happening:
If this is a third party application, you have not included some jar files on your class path;
Or, (which in my opinion is the most likely) you do not have a method which has this signature: public static void main(String[] args). This method defines the main entry point for your application, not having it might cause that error when you try and run the project. To my knowledge, Netbeans creates a main class with such a method automatically whenever you create a new project. This might be the reason why you are not having this exception when you create a new Project and throw everything in it.
You might be having an issue with Netbeans itself. You can start by either checkin gout this previous SO thread in which a similar (I think) issue is being discussed, or else, as a final resort, you might want to remove Netbeans and all its files, and install an earlier version. You can also try and see if you get the same issue if you use a different IDE such as Eclipse.
the solution is,right click your package in netbeans,go to properties,source now go to the jre option and choose your version,the programme will now run.

Categories