Format java source code

Could anyone tell me where can I find tools that could format the java and jsp source code, just like the indent program under unix(but it is for c/c++).
Thanks in advance.

I use jEdit, an open source editor written in Java, and there are at least two plugins for formatting code written for it... and they both are pretty good.

Similar Messages

  • How to read the Java source code (in Netbeans)

    I use OS X10.5.5, NetBeans 6.1 and JSE 6 on a 64 bit mac.
    When I downloaded NB6.1 it had JSE 5 as it's default (and only) java platform. I ran Software Update to get Java 6 from Apple, used the Java Prefrences utitlity to set JSE6 as default. In NB I added the JDK6 platform, registered the JDK6 javadocs and noticed that I also have the option of registering the Java source code.
    I have three questions:
    1) How do I make JDK6 the default in NetBeans. The JDK5 keeps being default after I did the steps above and I don't see anywhere to change that.
    2) How do I read the Java 6 source code? I can see sun provides [source code| http://download.java.net/jdk6/] for their supported platforms. I dont see Apple doing the same for its JDK port. What would I need to do to get to read the java SE6 sources? or is it actually hiding somewhere in the /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home hierarchy?
    3) Where does the JVM look for the binary code to run when I make a call to, say java.util.ArrayList or any other library. In my naivety I would have assumed it would be a .class file somewhere in the java Home folder, but I don't see anything like it.
    thanks in advance,
    chris

    This is taken from the help included with netbeans. In response to question 1.
    By default, the IDE uses the version of the Java SE platform (JDK) with which the IDE runs as the default Java platform
    for compilation, execution, and debugging. You can view your IDE's JDK version by choosing Help > About and clicking the
    Detail tab. The JDK version is listed in the Java field.
    You can run the IDE with a different JDK version by starting the IDE with the --jdkhome jdk-home-dir switch on the command line
    or in your IDE-HOME/etc/netbeans.conf file. For more information, see IDE Startup Parameters.
    In the IDE, you can register multiple Java platforms and attach Javadoc and source code to each platform. For example, if you
    want to work with the new features introduced in JDK 5.0, you would either run the IDE on JDK 5.0 or register JDK 5.0 as a
    platform and attach the source code and Javadoc to the platform.
    In  , you can switch the target JDK in the Project Properties dialog box. In  , you have to set the target JDK in the Ant script itself,
    then specify the source/binary format in the Project Properties dialog box.
    To register a new Java platform:
    Choose Tools > Java Platforms from the main window.
    Click New Platform and select the directory that contains the Java platform. Java platform directories are marked with a  
    in the file chooser.
    Use the Sources and Javadoc tabs to attach Javadoc documentation and source code for debugging to the platform.
    Click Close.
    To set the default Java platform for a standard project:
    Right-click the project's root node in the Projects window and choose Properties.
    In the Project Properties dialog box, select the Libraries node in the left pane.
    Choose the desired Java platform in the Java Platform combo box.
    Switching the target JDK for a standard project does the following:
    Offers the new target JDK's classes for code completion.
    If available, displays the target JDK's source code and Javadoc documentation.
    Uses the target JDK's executables (javac and java) to compile and execute your application.
    Compiles your source code against the target JDK's libraries.
    If you want to register additional Java platforms with the IDE, you can do so by clicking the Manage Platforms button.
    Then click the Add Platform button and navigate to the desired platform.
    To set the target Java platform for a free-form project:
    In your Ant script, set the target JDK as desired in the javac, java, and javadoc tasks.
    Right-click the project's root node in the Projects window and choose Properties.
    In the Sources panel, set the level of JDK you want your application to be run on in the Source/Binary Format combo box.
    When you access Javadoc or source code for JDK classes, the IDE searches the Java platforms registered in the
    Java Platform Manager for a platform with a matching version number. If no matching platform is found, the IDE's default platform is used instead.
    See Also
    Managing the Classpath
    Declaring the Classpath in a Free-Form Project
    Stepping Through Your Program
    Legal Notices

  • APT and Java source code generation

    Hi all,
    In many articles about APT tool, I read that it is possible to generate Java source code from annotations read by AnnotationProcessorFactory.
    I am very interesting by this possibility but I can't find an exemple (all exemples I found display informations only).
    Where can I find a concrete exemple of this functionnality ?
    Thanks
    Micka�l

    Micka�l
    I have a project on java.net that has several examples of code generation.
    Go to the project source code here.
    https://rapt.dev.java.net/source/browse/rapt/
    The ones here are quite simple
    https://rapt.dev.java.net/source/browse/rapt/src/net/java/dev/rapt/proposed/generators/
    and these packages are more complex
    https://rapt.dev.java.net/source/browse/rapt/src/net/java/dev/rapt/exploratory/#dirlist
    Check out the javadoc to see how they should be used.
    One pointer is, work out exactly what you want to generate first. Then code an example by hand, then make sure it compiles and does what you want it to do. That way you know exactly what you need to generate. It is much quicker to fix compiler and functional errors in your hand coded example, than to change the generator, recompile that, then run it to generate and compile the code.
    If you do find errors in your generated code, tweak the generated code by hand till it works, then go back and change the generator to do the right thing.
    A second point is: generate nicely formatted code, indented etc, then when it doesn't work, or doesn't even compile, you can at least read the generated code to debug it.
    Bruce

  • Error in compiling java source code in a package

    hi all...
    am having a problem in compiling a java source code:
    i have a class named 'Test' in the package 'packone'....
    i have another class named 'getTest' in the same package....
    in the class getTest i am taking a reference to Test class...
    on compiling i am getting the following error....
    cannot resolve symbol
    symbol : class Test
    The source code for the two classes are :
    package packone;
    public class Test{
    and
    package packone;
    public class getTest{
    public void me(){
         Test t = new Test();
    i have included the directory path in the classpath....
    still its not compiling .....
    please help
    thanks....

    Assume the current directory structure:
    C:\
    C:\packone...and that your classes are named Test & GetTest.
    My guess is that you're compiling within the directory C:\packone using the command "javac GetTest.java", which is wrong; You must use a path corresponding to the package-name.
    Move your command-line cursor to C:\ and type "javac packone\GetTest.java" and you'll be fine...
    Regards,
      /Håkan

  • Converting class files into java source codes

    Dear Friends,
    It is true that conversion of class files to its java source codes is possible through some software. I want to know, is there any way to protect my java source codes from viewing or copying illegally by other persons ?
    If I create JAR file from java files, can it be also convertible back to source codes ?
    Avi

    You can use code obfuscators in order to protect your code. And yes a jar file can also be decompiled.
    http://www.retrologic.com/
    http://www.2lkit.com/products/2LKitObf/
    http://www.codingart.com/codeshield.html
    http://www.drjava.de/obfuscator/

  • SQL Developer 3 EA2 - Problem with formating plsql source code

    I'm using sql developer 3 ea2. I have played with source code formating.
    I have 2 issues with formating in source code editor.
    I have a plsql string like the following extending over several lines.
    s VARCHAR2(2000) := 'SELECT
    col1, col2, col3
    FROM table
    WHERE col4 = :var';The result after apply "format" to my sourcecode ist:
    s VARCHAR2(2000) := 'SELECT
    col1, col2, col3
    FROM table
    WHERE col4 = :var';The second is that sql developer ist camelizing the previous line if I type a whitespace in plsql sourcecode.
    How to switch that off??
    The last issue is realy annoying!
    Christian

    I am having exactly the same problem. Every time you use Format Ctrl/F7 it adds new line feeds. Code starts off as:
    command := '
    select account_status, default_tablespace, temporary_tablespace,
    to_char(created,"YYYY-MON-DD HH24:MI:SS"), profile
    from Dba_Users@@
    where username=:1' ;
    First Format Ctrl/F7 get an extra blank line:
    command := '
    select account_status, default_tablespace, temporary_tablespace,
    to_char(created,"YYYY-MON-DD HH24:MI:SS"), profile
    from Dba_Users@@
    where username=:1' ;
    Then second Format Ctrl/F7, get THREE extra lines!!! It goes exponential!!
    command := '
    select account_status, default_tablespace, temporary_tablespace,
    to_char(created,"YYYY-MON-DD HH24:MI:SS"), profile
    from Dba_Users@@
    where username=:1' ;
    So far I've only really encountered the problem with dynamic SQL, which ignores the extra line feeds.
    i am pretty sure this is a long standing SqlDeveloper Format problem, going back to V2.

  • Java source code to compare XML based on ExamXML XML diff tool

    I’m working on a project that includes comparing XML files and I need a source code on Java to compare XML fragments.
    I’m using ExamXML from http://www.a7soft.com to compare XML files but I need the Java source code.
    Can anybody help me.

    You didn't notice there's a "Support" link on that page you referred to? Ask them for the source code. If they won't give it to you, then you are effectively asking us to give you a stolen copy of it. Don't ask for such things on this site.

  • How to beautify Java source code

    Hello!
    I'm mostly a Java developer, and I recently moved my projects to XCode. I was using jEdit previously, with a lot of plugins. I specially miss:
    * the ability to do vertical selections (jEdit, TextMate)
    * Gruntspud CVS plugin - but this can be run standalone, and I configured the default action to be /usr/bin/open so it opens the source and project files in Xcode.
    * and JavaStyle !!! This plugin "beautifies" Java source code. Sometimes, tabs are messed up and I want to clean up the code.
    Is there any JavaStyle-like plugin for XCode?

    * the ability to do vertical selections (jEdit,
    TextMate)
    Supposedly you can install 3rd party editors in Xcode. I have never done it though.
    * Gruntspud CVS plugin - but this can be run
    standalone, and I configured the default action to be
    /usr/bin/open so it opens the source and project
    files in Xcode.
    Xcode comes with a CVS plug in. Have you tried turning on SCM for your project?
    * and JavaStyle !!! This plugin "beautifies" Java
    source code. Sometimes, tabs are messed up and I want
    to clean up the code.
    I expect that a Java tool like JavaStyle would run from the command line. If so, you can probably wrap it in a script and install it in Xcode's script menu.

  • Where to download Java Source Code of Libraries?

    Hi Sir/Madam,
    Would you please tell me where can I get the Java source code of Libraries?
    Specifically for package sap.comcrmtcuserassembly.jar?
    I tried to look on to Downloads and Search but can't find it.
    Thank you very much in advance.
    -jemaru

    I've found it, the source codes are downloaded at:
    C:\usr\sap\J2E\JC00\j2ee\cluster\server0\apps\sap.com\

  • Where to find java source code on tiger?

    I'm taking a class on java, and i need to open up some of the java source code for classes like Abstractcollections and Abstractlist to see how their implementations work. Does anyone know where the java folder is located and how to open up the source on a mac? I've seen it done on windows( applications-java-java-sdk - unzip, or something like that), but it is not in the same place place on mac.
    I've searched through the folders named java but could not figure out which folder to open and how.

    Hmmm, are you trying to view the Source Code for Abstractcollections and Abstractlist, or find it, or compile it, or what exactly?
    Source code can be viewed in any text editor, but BBEdit, TextWrangler, & jEdit are really good...
    http://www.barebones.com/products/bbedit/threeway.html
    http://www.barebones.com/products/textwrangler/index.html
    http://www.jedit.org/index.php?page=download

  • Protecting java source code

    I heard about the possibilty of decompiling the java code and getting back the source code, is this flaw specific to java or is it common among all programming langauges?
    how is it possible to protect the source code? and how expensive is the solution?
    thank you

    Back to poster: To my knowledge, the ability tode-compile back to valid source code is unique to
    Java.
    No it's not. Any program files can be decompiledback
    to source code.
    If not their original C or C++ code, then at least
    assembly code.You cannot decompile C or C++ code to anything but
    assembler language. Which even when written by a good
    programmer is considered obfuscated by others. I
    doubt that anyone has lifted C or C++ code from
    another application using a decompiler.yes you can, all binaries can be reverse compiled, logically speaking they have to be!
    However, the readability of the output is not going to be as high as that obtained from decompiled java.
    >
    I would say that de-compilation is not a flaw in Javawhen compared to
    powerful features it has to offer. Of course it's a flaw (so I disagree with you here).
    People don't want this behavior, but it exists. As I
    stated earlier (and I'm agreeing with you on this
    one), it was an issue of priorites, and the
    developers of Java decided that it was OK because it
    allowed "powerful features"...it is a feature - whether it is a desirable feature is another argument entirely.
    >
    Here's a list of projects where the developers arenot interested in
    hiding the source code from you, in fact they let youhave it for free:
    Notice the words developers, not software companies.
    I believe in open source and participate in it when
    not bound by non-disclosure which is 99% of the time.
    But I would stand by my statement that there are no
    o software companies selling retail software that
    believe the ability to decompile Java back to Java
    source code is OK or good for them in anyway. I would
    gently suggest that providing open source code, and
    providing the ability to decompile to source code
    really don't belong in the same discussion...Protecting code is not the job of programmers, it is the job of the Law.
    rob,

  • Issue of Security about Java Source Code

    At most time Java compiler compiles the *.java source code into *.class files and then pack them in *.jar files running in the Java VM or as applet running on web pages.
    Recently I find a tool named cavaj that can decompile *.class files into *.java files. I tried it to decompile my *.class files and unvealed that the decompiled *.java files are the same of my source code!
    How to protect the source code not to be pirated? This is a big problem about the mechanism of Java. Is there any tool to compile *.java to *.exe files? Or is there any tool that can decompile *.exe to *.java in the future?

    This is a common question. If you do a search you will find many answers/solutions.
    But can it affect the performance of the program? Your program mayload slight faster, but the runtime performance is the same. It may effect your performance as it takes some time to get the obsufaction right, especially if you are using reflection.

  • How to save the user-defined Java source code

    Would you please tell me how to download all of the java source code in one software component.

    UDFs can be exported one by one as a .mte file...not at one go...

  • Generate java source cod/ contect menu

    I am new to JDeveloper, so please excuse the ignorance. I am using JDeveloper 9.0.3.10.35 and UML modelers 9.0.3.9.4. I am going through the JDeveloper tutorial( Modeling Java Classes tutorial). I design a Class model and i try to generate java source code for some of the java interfaces in the design. The tutorial sates: Choose Generate|Java from the contect menu.
    Any idea where is this mysterious conext menu? There is a generate option under model but every thing is grayed out...Any help would be appriciated.

    Thanks Lisa. The problem really was with the poor instructions provided and a tired mind. There is no "context menu" ala right click on something BTW, right clicking on the main design page does not do any thing and right clicking a class only gives the properties. Anyway, what was meant, i think is to select Java from the main menu "model" and then select Generate/Java. Now since the code is "automatically generated", the Java option was grayed out and that threw me off.
    To descover all this i re-did the whole tutorial with only one class and viola, the code was there.

  • Access Java Proposals for a java source code programmatically

    Hi,
    Problem
    Programmatically get java proposals for a java source code (not byte code) via eclipse bundle
    Description
    I am developing one eclipse osgi bundle to correct java source code automatically. I am running osgi bundle inside eclipse itself [Version: Mars Release (4.5.0)]. I am able to get java project object and a class object inside it which I want to correct. Every time I try to collect java code proposals as I put one test file which can be corrected (like duplicate imports), I receive below error:
    Java code line
    JavaCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { problem }, proposals);
    Error description
    !ENTRY org.eclipse.jdt.ui 4 2 2015-07-27 18:57:09.196
    !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".
    !STACK 0
    java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.install(ASTProvider.java:236)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.<init>(ASTProvider.java:227)
    at org.eclipse.jdt.internal.ui.JavaPlugin.getASTProvider(JavaPlugin.java:741)
    at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
    at org.eclipse.jdt.internal.ui.text.correction.AssistContext.getASTRoot(AssistContext.java:119)
    at org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor.addUnusedMemberProposal(LocalCorrectionsSubProcessor.java:669)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:530)
    at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:316)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:378)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:339)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:335)
    at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:468)

    Any code from org.eclipse.jdt.ui (or the non-API code in org.eclipse.jdt.internal.ui) is likely to require a running workbench. Only the code from org.eclipse.jdt.core is guaranteed to work headlessly.

Maybe you are looking for

  • Step by Step Deploying ADF Faces to OC4J 10.1.2

    Hi there, I've already read the previous topic about deploying ADF Faces to OC4J 10.1.2. But I'm still getting failed to deploy it. Some clue that I know are: - Using JDK 1.4.2 (not 1.5) - Using J2ee 2.3 (not 2.4) - Using ADF Runtime installer to OC4

  • Change of Jtable feature select in 1.5?

    I have a JTable Object, with 12 columns and 32 rows. when the user want to populate the first eight rows there is no problem, they begin ant the rown 0 column 0, But when the user want to capture only from the 9 to 16 row, they select those range, bu

  • Problems related to the device application Blackberry

    Hi All I ma trying to create the sample application on Blackberry. I followed the following steps: 1. On sybase 1.5.2 workspace i created a mobile application project. 2. Dragged customer dba and sales order dba on the diagram scree. 3. Created the r

  • Getting the Network errors

    Hello Experts, One of my customer has the following issue: Getting the Network errors when the following batch script is executed through a scheduler or through a command prompt. login "$1" "$2" on "$3"; alter system kill request on application SEMPC

  • Can't get TV Shows to show on iPad

    I downloaded 2 tv shows from iTunes and they show in my library on my computer. I've tried syncing several times but when I try to view the tv shows on my ipad, there isn't even a "TV Shows" tab in my library on the iPad. How do I get it to show on m