How to arrange java code in proper way [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
the code in .java file is not arranged or not in a formatted way.
Can anyone suggest me a software that can format or arrange the code in good manner.
for e.g. I have code like this...
class a{ public static void main(String s []){}}
but i want it arrange in a proper way like this
class a{
public static void main(String s[]){
}
}

I can suggest you to use Netbeans, you will get these advantages,
Formatting your code properly is very easy in Netbeans
If you make a new class, The class is shown with all formatting done,

Most IDEs these days (Eclipse, IntelliJ, NetBeans, ...) have code formatting capabilities built into them. They have many options to setup the exact style for you.
If you are not using an IDE, get one, Eclipse is free! :)
Or you could try something like Jalopy (it's a free version of a similar tool: JIndent)

Chances are the code you have copied has line breaks that are not compatible with your OS.
I would recommend getting an IDE like Netbeans or Eclipse and putting the code there, as they have linebreak adapters.
No need to manually insert your native linebreaks.

I would suggest you to use Eclipse IDE.
http://www.eclipse.org/downloads/
Eclispe has a default integrated code formatter and you are able to customize this feature:
http://www.ralfebert.de/blog/eclipseide/source_formatting/
You can also say eclipse to performe code formatting everytime you safe or run the code, so you normaly never need to format code by yourself.
Alternativly you could use netbeans, which is an open source ide as well which supports code formatting.

Related

I want to write my java program from command prompt(no netbeans, no notepad) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Anyone here remember how to write a java program from command prompt.
Earlier (5-6 years back) before BlueJ came, we use to write java programs in a Blue Black screen that is similar to one in TurboC++.
My system has netbeans installed, all paths are proper, I can even compile the programs by writing them in a text file with .java extension.
But i would like to do that in previous environment(see the image below), where we use to create the files, save them as .java, then go back to command prompt and execute the statements.
I got the image from google, but didn't find a way to open this.
A couple years ago, I spent a long time doing all my Java coding in Vim. It's easy enough; you learn the basic API enough not to depend on intelligent completion, and there are Vim features (like ctags) to give you a similar feature, though it's based on text rather than actual functionality. It also has Java syntax highlighting. It should work fine on Windows.
Build the project with Maven, and you're good to go.
You should probably install Cygwin. Spending time in the Windows command prompt is not good for your sanity.
Also, many Eclipse features can be accessed from the command line in a headless manner. I used to run the Eclipse formatter that way, so I could use my team's standardized format. I believe there are projects that let you access most Eclipse features directly from within Vim, if you want to go that way.

Generic java bug-estimator [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I heard there is software available that you can feed Java-code and it gives you back an indication on where your code is likely to produce unexpected behaviour. However, I cannot find such software, nor anything resemblng this. Does anyone have an idea on where to look? (I don't know where I heard this, so no, I cannot go back to the source and ask :( )
For example:
-it might check whether the same code is found at multiple places (when editing you are likely to forget to update one of the two, hence this could give prblems in the future)
-it might check whether you might be returning null somewhere where the null stays untreated,
-it might check for 'magic numbers' (numbers that are used in code without being assigned to a variable), especially when these numbers appear at various places in the code.
-etc, etc.
(What it doesn't need to check is whether the code can be compiled. that's, ofcourse, where we have already many other tools for, like Eclipse).
I do not know for certain whether the described software exists and what it looks like, but any help in this direction would be great!
Sounds like the code inspections you find in IntelliJ Idea.
There is FindBugs which does a static code analysis to find "bug patterns". That is code that falls in one of these category:
Difficult language features
Misunderstood API methods
Misunderstood invariants when code is modified during maintenance
Garden variety mistakes: typos, use of the wrong boolean operator
It's nice to use and tends to find some bugs. However it can not do everything you want (i.e. "returned null" checks).
There are a few tools like this. I've found PMD and Findbugs particularly useful.
findbugs is one such tool. More generally, what you're talking about is called static analysis.
If you work with eclipse, you could use codepro
Use sonar. It is a web application that has all these functionality and nice UI. Visit the site (http://www.sonarsource.org/) and see nemo - the live instance where all jakarta projects are hosted: http://nemo.sonarsource.org/

Where can I find a Java library for code highlighting? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm trying to find a Java library to highlight code. I don't want to highlight Java code. I want a library that will easily allow me to highlight a macro language of my own, in a code editor of my own written in Java.
JSyntaxPane is decent. Advanced and decent IDEs use either Lexer/Parsers such as Antlr and Javacc or regular expressions. Implementing it correctly is not a trivial task.
As you mentioned "a macro language of my own", I suggest taking a look at Lexer/Parser generators for Java and maybe JEdit syntax package source code(google it, reached the maximum hyperlinks) for lexing strategies.
GesHi is pretty good. There is a list of highlighters here.
UPDATE: missed that you wanted a java lib. Try jedit syntax package.
You might look at the Java port of GeSHi named JaSHi. It looks like it is a complete rewrite of the popular PHP package, with Java bindings.
JSyntaxPane may be the way to go. It will highlight a number of languages and is extensible to handle others.
You may want to take a look at xtext - it does a lot more than syntax highlighting; in fact, you only have to define a grammar, and it will generate an eclipse editor plugin with outline, syntax highlighting, syntax checking and autocompletion automatically. It could save you a lot of work if an eclipse editor plugin is an acceptable end result for you.

Best source code formatter for Javascript? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've been digging through Stack Overflow as well as a number of Google searches, and I cannot find a satisfactory code formatter for JavaScript.
I have found several related tools, such as syntax highlighters and pretty-printers, but I am looking for a tool that I can ideally create a wrapper for in Eclipse and simply run from the menu bar. Hence, if any Java-based ones are available, that is a big plus. Free and/or open-source is preferred as well.
I am looking for something that my development group can use to maintain a consistent code style.
Edit: Thanks to kRON for linking to the format customizations page.
Edit: Related question on Stack Overflow.
This is by far the best I've come across: http://jsbeautifier.org/
Available as an online tool, or on the command-line using node.js or python.
The source code is available.
In one breath: Aptana Studio! Yes, it's Java based and free (Eclipse, as standalone or plugin).
You can also customize the formatting.
If you already use Eclipse, I recommend you to try Aptana, you can install it as an Eclipse Plugin.
For Eclipse IDE you can use JavaScript Code Formatter based on Goolge's Style Guide
For IntelliJ IDEA you can use the same js code formatter xml file , but previously you have to install a special plugin Eclipse Code Formatter Plugin, which solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used
If you also need Java programming I can recommend 'IntelliJ IDEA'
It offers excellent JavaScript formatting and refactoring out of the box.
Have you tried jsfiddler. It's great for trying things out with Javascript. Built in JSLint & something called Tidy. Not sure whether that infers jstidy Piotr Zalewa is the guy who wrote it. May be worth giving him a Tweet #zalun to confirm.
If you are using notepad++, you can try jsminnpp plugin

Automated Python to Java translation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?
Actually, this may or may not be much help but you could write a script which created a Java class for each Python class, including method stubs, placing the Python implementation of the method inside the Javadoc
In fact, this is probably pretty easy to knock up in Python.
I worked for a company which undertook a port to Java of a huge Smalltalk (similar-ish to Python) system and this is exactly what they did. Filling in the methods was manual but invaluable, because it got you to really think about what was going on. I doubt that a brute-force method would result in nice code.
Here's another possibility: can you convert your Python to Jython more easily? Jython is just Python for the JVM. It may be possible to use a Java decompiler (e.g. JAD) to then convert the bytecode back into Java code (or you may just wish to run on a JVM). I'm not sure about this however, perhaps someone else would have a better idea.
It may not be an easy problem.
Determining how to map classes defined in Python into types in Java will be a big challange because of differences in each of type binding time. (duck typing vs. compile time binding).
Yes Jython does this, but it may or may not be what you want
to clarify your question:
From Python Source code to Java source code? (I don't think so)
.. or from Python source code to Java Bytecode? (Jython does this under the hood)

Categories

Resources