Compiling CSS to SWF server side Java, What is the best practice? - java

My project allows users to create custom css for our flex app.
In regards to compiling the CSS into SWFs on the server side:
Should I use the flex2.compiler.css.Compiler class in mxmlc-3.5.0.12683.jar?
Or
Should I invoke mxmlc from Runtime.getRuntime().exec()?
The css.Compiler class is not very well documented. Does anyone have any examples that use this?
For the Runtime exec method, what is the best way to package mxmlc into the maven build so its available to the server at runtime?

I think it is so rare that people try to compile Flex Apps on the fly at the server, that there probably isn't a best practice. My intuition is that using the jar file makes more sense if your server side code is Java.
But, if documentation is a problem the Flex command line compiler arguments are well documented and may save you a lot of time.

Related

How to create and use class instances in C# from JAR files?

I'm aware of all the other questions about this topic, but I haven't found a good solution for my problem. Currently I am trying to use Java code in my C# project. I've already tried to convert the JAR files into .DLL files with IKVM, but this didn't work for me because the JAR files are to complicated to translate into C# because not every component, which were used in Java, can be found in C#. The normal call of the JAR file doesn't work for me either because I need to work with the class instances of the declared classes in the Java code.
Back to my question: Does anybody know how I could use Java code in my project? I've heard that it may be possible to implement Java code like it would be native, is that true? Note that I've to work with the class instances of the classes declared in the Java code.
I highly appreciate any kind of help, sheers!
Edit:
My work around would be that I include batch files, which are calling the JAR files. I will include these batch files into my C# Project and work with the batch files. This may be a even better approach for me because every input and output of the JAR files are done via XML files.
This kind of mixup are not generally a good approach. I think the .Net Framework is very mature and you can find everything you want to do your work.
I would suggest you the following approach :
You can wrap your Java library in a REST API and call it in your C# code. Your REST API can be hosted on an external server or use an embedded server or even a spring boot project.
You can read this post for more details.

Library to access Javadoc from Java

I want to find a library that I can use from my Java application that will allow me to access specific Javadoc in the scope of my project (I specify where Javadocs are located). Just like in Netbeans, I want to potentially access the Javadoc from html files locally and remotely, and from source.
I expect that I could use code from Netbeans to achieve this, but I don't know how, and I can't easily digest their documentation.
Today I started thinking about the same thing.
From CI point of view, I could use #author annotation to send e-mail to someone, who wrote a test that is failing with error, not with a failure.
Google didn't help me (or I didn't google deep enough), so I started wondering how to do it on my own.
First thing that came to my mind is writing a little tool that will check all *.java files specified in a directory, bound file name to annotations and allow user to perform some actions on them.
Is that reasonable?

Execute Java code which is stored in String

I was wondering about the possibility to send Java Code to a servlet that the servlet will take and execute it?
For example I would send a chunk of code as String, which will be added and executed. Can anybody think of a way of how I would approach this?
This is certainly possible - you could send the compiled bytecode Base64-encoded, then decode it at the servlet and use a classloader to load it.
Or you could send a jarfile similarly encoded, save it to disk and add it to a custom URLClassLoader.
You may have major security issues if the code is untrusted, though.
See What are the security risks I should guard against when running user-supplied Java code?
tools.jar from JDK contains classes to compile Java code (used by Ant etc.), you can also use Eclipse compiler, if you want. It is possible, but from security point of view (code injection etc.) it would be disaster ;)

Is there any program like LINQPad for Java?

I've found LINQPad to be extremely useful when answering StackOverflow questions for C# or VB.NET. It allows me to write up some quick code, run it, and (if I want) see a nicely-formatted dump of the results. That way I can be sure that the code I post actually runs. Thus far I haven't seen anything that I can use to achieve the same result with Java. Is there anything like that out there?
I am not looking for something to query data sources; I just want a light-weight IDE. These are the features I'm particularly interested in:
The ability to write and run short snippets of code without establishing a whole project or file structure.
Reporting of compiler and runtime errors in the code when it is run.
The ability to add references to a particular editor instance.
Syntax highlighting and Autocomplete/Intellisense would be a plus.
JPad - A java scratchpad for running snippets
Since I also couldn't find one I've decided to write one. Currently it can:
Run java snippets (no class / imports / public blah... needed).
Contains drivers for MS/MySQL/Postgres.
Output results as HTML tables
It's very rough but I will add to it over time. Feedback is definitely welcome.
This may help : http://www.browxy.com:9000/codeRunner
EDIT: Url seems to have changed to http://www.browxy.com
You can use the Groovy web console ; it's possible to speak java in groovy land.
Java Snippet Runner:
Does something similar to Linqpad (jar file, not just for macs)
http://mac.softpedia.com/get/Development/Java/Java-Snippet-Runner.shtml
Code Runner (Commercial):
for Mac's only, it'll run code snippets in Java, and lots of other languages too (e.g. Objective C)
http://krillapps.com/coderunner/
http://ideone.com is an online service that has the features you want.
I've been using JEdit for a long time, which is a very powerful cross-platform editor, NOT an IDE. It does have plugins to execute Java code right in the editor, and even uses BSH for macros.
I was looking for a "Java LinqPad" also, and i came across :
this
I've been using IntelliJ IDEA and it works really well as a Groovy scratchpad. The Community Edition is free too.
You need to create a new project, but then can add Groovy scripts to it and run them on the fly. Not had any luck with the actual Scratch File functionality though.
Being a Jetbrains editor it's pretty slick too. (Unlike some of the other options)
Nothing beats LinqPad though.

How do I get my simple Java web service to work?

In a textbook exercise, we make 3 Java classes and an XML file.
My questions are:
Where should I save these .java files? I'm using NetBeans 6.5 so the default is My Documents.
What should I name the XML file?
I am using XAMPP so the file WSDL.xml I put in xampp/httdocs but when I open 127.0.0.1:9876[/]ts?wsdl it says page not found.
Note: I do not need to know how to create a Java class. I need to know where to put the file in which the class is defined.
Subjective opinion:
If you don't know such basic things such as placing java files into right directories, perhaps, you should first try a few much simpler examples, than creating a web
service.
In Netbeans, you can create a Java project, than add Java classes by doing
File -> New... -> Java -> Java Class
To learn how to use Netbeans, visit:
http://netbeans.org/kb/
Especially "NetBeans IDE Java Quick Start Tutorial" might be helpful to start.
Furthermore, you don't run Java webapps with some kind of XAMP,
but with Java web servers such as Glassfish or Apache Tomcat.
Both these servers are bundled with Netbeans when you use
Netbeans Java profile (see table at Netbeans download page)
I think you should follow ivan_ivanovich_ivanoff's adive and start with the basics.
When you have done that, you might want to come back here and read my answer to the question Stack Overflow: Simple Java web services. It assumes you know how to compile a Java class and how to package it into a JAR, but since these are pretty basic tasks you have to learn anyhow, it might help you getting your web service up and running.
Look at the example code provided with the book.

Categories