Compiling Javascript with Netbeans - javascript

I have experience using Netbeans with Java but am new to using it with Javascript. I know how to open javascript files within a Java Project but is there a way to open javascript in a "javascript project" where I might be able to "compile" the code and see possible errors. Is this possible or am I asking too much?

By compile, I'm assuming you mean simple validation (like using undefined variables or typos etc.)
I may be wrong, but netbeans has the worst javascript support. If you want simple validation of Javascript code, you may look at Eclipse javascript environment (or the Aptana plugin). IntelliJ IDEA has very decent validator as well.

To check for code quality you can use some JavaScript analysis tools like JSLint.
http://www.jslint.com/
But it's not nearly as good as compilation in a fully typed language like Java.
An alternative is to not write the JavaScript at all but use Java instead and have it converted to JavaScript. This gives you the advantage of writing fully typed code that can be statically analyzed and checked for errors. Google's GWT does this and there are other similar options.
http://www.artima.com/lejava/articles/java_to_javascript.html

Related

Using Aptana Studio for Extendscript

I've been using Sublime Text for creating the Javascript flavor of Extendscript scripts for our company. However, I've been curious about Aptana Studio and whether or not it might be a better choice to move to it. Already, however, I can see two big issues:
Handling Extendscript-specific code
Content assist using a DOM.
In the regular versions of Eclipse, if I wanted to use a specific piece of code from a library and get content assistance with it, I'd just add its .jar file to my build path and I was done. However, Javascript doesn't seem to use libraries, per se, so how would I get it to know the various methods and properties of a TextField object when I use the ol' Ctrl/Cmd+Space after typing in a reference to one, followed by a dot?
And at the beginning of my scripts, I have to use preprocessor directives, such as:
#target indesign;
#targetengine session;
so that the script knows what program I am using, if I want to #include other files, etc. These commands are, of course, specific to Extendscript, so when Aptana sees them, it breaks the Javascript syntax highlighting for the rest of the document. Is there any way to set Aptana to, perhaps, ignore preprocessor directives? Or add their syntax into its rules checking for syntax highlighting?
Also consider the ExtendScript Toolkit, if you haven't tried it yet. While it's not as powerful an editor, it does know about some of the DOM functions, and it has convenient built-in debugging tools for working with CC applications.

Does any ide give list of js functions inside php?

I use Eclipse to edit php files. It gives me the list of php variables and functions in the otline window.
Is there any IDE (free of charge) that would provide list of javascripts that are inside my php file?
I have lots of them and it would be much easier to navigata with such a list.
Netbeans for php and Aptana studio should do it and they have also an integrated javascript debugger.
I'm also sure PhpEd does NOT have this function because i use it and it's a feature i want.
Intellij idea does this. it can recognize languages within languages with a bit of config. Ive only ever used it for javascript within jsp and html, but i see they have a php app
Dont be put off by "Most advanced Java IDE" in the title. Its a great java ide, but it supports many other languages via plugins. Currently im using it to code in python for example.

Break up JavaScript file into more manageable, or using different IDE

I use Dreamweaver for development, mostly PHP, html, css, javascript. Is there anyway to break up JavaScript files? or maybe a better IDE that makes it easier to work with? It just becomes quickly difficult to read and find what I'm looking for.
Thank you!
Intellij and/or Webstorm by Jetbrains has the best JS tools I have found. It has very good (as good as it gets, for JS) intellisense (autocomplete for variables and methods) as well as refactoring for variables and methods. You can cmd+click into method definitions from anywhere, as well. Unfortunately you need to pay for them, but if you are using Dreamweaver you had to pay for that. If you are only doing html/css/javascript Webstorm is the way to go.
Yes, you should break up your javascript files into relevant parts just like you break up your php files into relevant parts. The one key factor here is they should be combined and minified before being served up to the browser so the user does not have to make several network calls to your server for each .js file.
Check out Google Minify for an easy solution to that issue.
Take a look at the JQuery source to see how they divvy up their files. Now look at their combined framework, and of course their minified framework. What is actually served up to the user looks nothing like the source.
Uh, Dreamweaver?
Definitely use a different IDE. Aptana won the poll here :)

How to use coffeescript in developing web-sites?

How do you use CoffeeScript? It need to be compiled, so - you write code in CoffeScript, compile it, and insert real JavaScript on your site?
Doesn't it take a lot of time? Or is there some another way?
P.S. I've seen another way - to insert in development stage coffeescript in text/coffeescript script-tags with coffeescript.js library (about 150k), and compile only for production version and insert real Javascript.
The answer is yes, you compile it and include the generated JavaScript on your side.
If you're using a web framework (rails, django etc) you should take a look at the following list of coffeescript plugins: https://github.com/jashkenas/coffee-script/wiki/Web-framework-plugins. They will compile your coffeescript to javascript when you deploy your app to a server.
Using the coffee-script plugin with the text/coffeescript tags is another option, gzipped and compressed, its only about 39kB, but that can add up if you include it on pages that get many hits and I don't think is a good idea when you can compile the coffeescript to javascript yourself without needing the plugin.
There is the middleman plugin which will lets you work with CoffeeScript during development, then compile and minify it for deployment.
When you are first learning coffeescript, you will almost certainly want to do your compilation manually during development, because you will probably find, as most of us do, that you need to be able to look at the javascript code in order to debug and find out what's going on. The more fluent and comfortable you become with coffescript, the less often you will need to refer to the javascript code.
I think this will probably be true no matter what your level of expertise in javascript. If you are a javascript pro, you will be dependent on looking at stuff you are familiar with, until you start to figure out how coffeescript works. On the other hand, if you are completely or partially unfamiliar with all the quirks and subtleties of javascript, such as prototypes, the javascript approach to scope and globals, and all the rest, you'll find yourself digging into javascript references, and cross-referencing the javascript code with your coffescript code, until you get familiar with it.

Is there a Java byte code reader implemented in javascript?

I know there are lots of libraries that read byte codes that are written in Java. Does someone know of a byte code library that is implemented in Javascript?
Since javascript is typically run inside a browser, it generally cannot read the actual bytes out of files, which makes it less-than-ideal for reading java bytes. If you somehow got the byte codes encoded in a form that the javascript could read, what would you expect the library to do with it? Can you provide more details about what you're trying to do?
If you're looking to be able to write code in Java, and have it run inside a browser, take a look at GWT. It uses Java to recompile your byte-code into optimized javascript.
Edit
Based on your added comment, that you are hoping to "find out the classes and methods used in a jar file on my local disk":
Since javascript is unable to access files on a local disk (at least, without using ActiveX), the technology simply won't allow for this sort of thing. Is there a reason you wanted to use javascript for this, rather than java?
And please accept my apologies if it sounded like I was questioning your motives. I really just wanted to get enough information to be able to adequately answer your question.
Update:
It looks like the Japanese project I tried to link to below is long gone.
In any case, time has passed and now there are a couple of hits for "jvm in javascript" on Google. Namely:
Doppio
BicaVM
Look what I found:
http://ejohn.org/blog/running-java-in-javascript/
Does this help?
Edit: unfortunately it looks like the original project's site is dead.
You could try through the Web Archive, here (in Japanese, tried to Google translate it, but I guess it was too much indirection :))
For goodness sake, if you follow that link, run your download through an anti-virus.
I don't know if it's trustworhty.
There are compilers which can compile Java to JavaScript. As a last resort, you can use one of those compilers to take a JVML bytecode disassembler written in Java and compile it to JavaScript. One example of such a compiler is GWT.
Similarly, there are compilers which can compile JVML bytecode to JavaScript. Again, you can take one of the above JVML bytecode disassemblers written in Java, use any Java-to-JVML compiler (javac, ecj, gcj, …) to compile it to JVML (i.e. .class files), then compile those .class files to JavaScript.

Categories