Can I change the LookAndFeel of a Java Webstart Program - java

((I'm an industrial construction engineer (recently graduated) and at the place I recently started working we use a Java Program, developed by an external company, to calculate the price of industrial buildings including everything.))
I have a html link on my desktop and it starts a Java Applet/ Web Start (?), I have to click Run, and after that a new (native windows) window pops up with the program running in it.
Everything looks super old, ugly skin, bad fonts, I hate it. In old manuals (2013) the program (on screenshots) has a native windows look and feel.
However, the most recent versions look SHIT.
Question: Do I have to contact the writer of the code # the external company to change the look and feel back to native OS?
Or is there someway for me to crack into the code and force a parameter or something?
I'm kinda noob at Java but I'm a quick learner, shoot.

You can try to set the nimbus look-and-feel. You need at least JDK 6 for nimbus. There are more ways how to do it: https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html
As you can see on this link, you can do it programmatically inside the java program.
BUT there are 2 other ways how you can do it by configuration:
1.
Permanently set the default look and feel to Nimbus by adding the
following line to the JAVA_HOME/lib/swing.properties file:
swing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel
If the swing.properties file does not yet exist, you need to create it.
2.
Specify Nimbus as the default look and feel for a particular
application at the command line, as follows:
java -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel MyApp
In the 2nd case the java command line (in case of JWS) is coming from the .jnlp xml descriptor which is part of the deployed JWS application jar file.
There is a resources section in the .jnlp which looks something like this:
<resources>
<j2se version="1.7+" java-vm-args="-esa -Xnoclassgc -Xms32m"/>
...
</resources>
which you should extend with the nimbus property values like this:
<resources>
<j2se version="1.7+" java-vm-args="-esa -Xnoclassgc -Xms32m"/>
<property name="swing.laf" value="com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" />
<property name="swing.defaultlaf" value="com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" />
...
</resources>
to get the intended java command line created.

As almost everything in the programming...
It depends. There's a way to get java code from the jar file (The term java developers use is "decompile"), but there's a process called "obfuscation" wich prevents this sometimes. There's a high chance, that the the program you use contains obfuscated code. If the code is obfuscated then you get an uncompilable code, and you would need to pretty much rewrite the whole codebase.
This is not the only problem, deobfuscating code is not 100% illegal, but you are permitted, to share the code or the recompiled program. Keep this in mind, if you choose this path.
To decompile a jar file, you can use jd-gui. Then you need to save the java files you get to a directory. You can open these with a normal text editor, but I'd advise you to get a java IDE, such as Eclipse.
After this, it's pretty easy to change, how a GUI looks. You can check java GUI tutorials about this.

Related

C++ or Java Library for automated code editing?

I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files).
Is there a C++ or Java library that
Can recognize and output names of classes/functions within a text file
Can recognize and output the names of the input arguments for said classes/functions
Can allow me to insert code at specific lines or within specific functions
Can search for a given variable name/value
Maintains original file formatting
I would prefer not having to manually code something to do the above, so any help would be appreciated.
Thank you in advance!
EDIT: I currently use Eclipse, and am unsure of how to proceed. So to further explain my question:
In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened?
Also I will explain the 'purpose' of this project to further clarify. I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process.
Thank you, again.
Much of what you need can be found in a modern IDE; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). You might look there to see if there are modules that suite your needs.
Looks like you are talking of a tool like eclipse. You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE.
If you wish to make one of your own, you can do that using eclipse rich client platform.
All that you would need from Java is the reflection API.

Open With... a java program

I want to know how to make a java program that can be used to open stuff up. Ex: notepad++, win zip.... Do I have convert the jar to .exe first? Also, does the file chosen get passed in to String[] args?
By the way, I know that it works with cmd but thats not what I'm asking.
Depends on the OS. Under windows, you need to attach some details into the registry.
Have a look at the 3rd answer in Utilising a file association in a Java application for an example?
You could also have a look at http://www.rgagnon.com/javadetails/java-0592.html
UPDATE
Also, when the OS executes the program, you should receive the file as a command line parameter through the main method
I don't know if this will work suit your needs or not, but you could also take a look at File association in Mac
There's many choices on how to make a Java program runnable. Like you mention, the simplest choice is to use the command line. If you want to make it work with most OS's GUI interfaces (and the Open With dialog) the easiest choice is to make an executable jar. IDEs can make this very easy for you, in Eclipse just right-click on the project and select Export > Java > Runnable JAR file.
Another excellent option is to turn your application into a Java Web Start application, which lets users easily run Java programs being served up online.
Alternatively, like you mention, you could convert it into an .exe file:
Compiling a java program into an executable
How do I create an .exe for a Java program?
How can I convert my Java program to an .exe file?
Deploy the app. using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
Here is a demo. of the file services in which the app. is associated with the file type .zzz.
..does it get passed via the windows file chooser?
No. It gets passed to the main as either -open filename or -print filename. What the app. does with those strings is up to it. The demo. linked above will prompt the user in the sand-boxed version, simply because it is sand-boxed. The other one should work without showing prompt or dialog.

Debugging with jdb

Trying to figure out my way around Sphinx 4 (the CMU speech recognition engine in Java), I tried to use a demo included with the distribution by altering it to what I wanted it to do (the name of the demo is Aligner). I am running into problems and want to use jdb from the command line for debugging the same. I read the documentation given here, but it is limited and does not have a solution to my problem, which in brief is as follows:
I invoke jdb like so:
jdb Aligner (name of the main class of the project).
Set a breakpoint like so: stop at Aligner:33
The output I get (on the command line):
Deferring breakpoint Aligner:33.
It will be set after the class is loaded.
In the file demo.xml (which is the makefile equivalent for this Project),
javac debug=true is mentioned.
My questions:
1. Where should I invoke jdb from? Should it be invoked from anywhere in the entire sphinx directory or should I invoke it from the same directory as Aligner.java?
2. How can I use jdb with the jar for this project?
P.S: I know I can use Eclipse with this, but I am not sure I know how to do that. My first priority is to get this up and running.
P.P.S: I am a Java newbie and do not know much about the language. My preference for the command line comes from my background of C/C++ programming on the command line.
Any help is most welcome,
Thanks!
What are you actually trying to do?
If you are not so familiar with Java, why not use Sphinx3 or pocketsphinx, both of which are implemented in C?
http://cmusphinx.sourceforge.net/wiki/download/
Also, you might get better responses on this topic by checking the forums on the above site, or checking in to the IRC channel #cmusphinx
Finally, you mention that your program name is 'aligner', which makes it sound like maybe you are trying to do forced alignment? There are already existing tools for this in the sphinx3/sphinxtrain/pocketsphinx packages and it would probably be worth your while to check them out.

Java webstart character encoding issues

I have a JavaFX/Groovy application that I'm trying to localize.
It turns out that when I use JavaFX standard execution with the Java VM arg "-Dfile.encoding=UTF-8" locally, all of my international characters (for example, ü) display correctly.
However, if I invoke the app via a JNLP file, using java-vm-args="-Dfile.encoding=UTF-8" e.g.
<resources>
<j2se version="1.6+" java-vm-args="-Dfile.encoding=UTF-8"/>
...other stuff...
</resources>
The application shows international characters as a couple of other random characters (like √¬).
Am I specifying the file encoding incorrectly in the JNLP, or is there some difference between Standard Execution and Webstart that affects this?
Much Appreciated.
EDIT: I am using a Groovy API to access the Remember The Milk RESTful web service. All text that is problematic will come from data retrieved (like task names) and is not actually stored on disk in binary or text. It's curious that "-Dfile.encoding=UTF-8" would actually fix it locally.
I would strongly advise you to explicitly specify the encoding everywhere you're going to be converting text to binary or vice versa. Relying on the JVM default - even after you've set that default - doesn't feel like a good idea to me. You haven't really said what you're doing with text, but if you explicitly set the encoding when you save or load, it should be fine.

Help with IzPack - Creating Java and JNLP One Click Installations

I took the advice I've been given here to look at IzPack to create a JNLP based one click installation for computer illiterate clients who are using a Java desktop application I've created.
Java Web Start Driven Installation
However, I can't seem to find my way around it.
I don't know where to begin and seems the online tutorials are basic "look at the examples" which are themselves pre compiled and not sourced.
I want to create a simple form - be it in JSP or the JNLP install app (preferably JSP and the JNLP should get arguments from the JSP that launches it).
Then when the users click Install, the program installs to the default directory of userappdata with no questions (except for the UAC).
But IzPack seems to be forcing me to use panels and stuff... Not sure I want all of that.
Or maybe....
Hmmm, writing this just gave me an idea, but I'd still like some feedback.
Thanks.
Another approach perhaps?
If all what you need is to allow the user invoke a JAR, then consider using JSmooth to wrap it in an exe file. The exe file knows how to invoke java correctly and prompt the user to download if not present.
We also have used one-jar to wrap multiple jars in a single jar for exactly this purpose.

Categories

Resources