分类: Eclipse Coding

  • What are the reference infos when using Eclipse Batch Compiler

     

    When reading through the Eclipse Batch Compiler Documentation for Java, I came accross the flag -referenceInfo whichs description is as follows:

    Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.

    What are does reference infos? Are those infos about object references? Is there any documentation available?

    ——

    These reference infos are used when the Eclipse Java Compiler is used as part of the Eclipse Java IDE (as so-called project builder).

    Therefore, there will probably be no documentation for this. But in the code you can see which data is gathered with -referenceInfo during compilation (see org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope):

    if (compilerOptions.produceReferenceInfo) {
    this.qualifiedReferences = new SortedCompoundNameVector();
    this.simpleNameReferences = new SortedSimpleNameVector();
    this.rootReferences = new SortedSimpleNameVector();
    this.referencedTypes = new LinkedHashSet<>();
    this.referencedSuperTypesSet = new HashSet<>();
    this.referencedSuperTypes = new ObjectVector();
    } else {
    this.qualifiedReferences = null; // used to test if dependencies should be recorded
    this.simpleNameReferences = null;
    this.rootReferences = null;
    this.referencedTypes = null;
    this.referencedSuperTypesSet = null;
    this.referencedSuperTypes = null;
    }
    I guess (but I’m not sure if it’s true) that for instance the referenced super types are collected e.g. to be able to quickly display a type hierarchy in the Java IDE.

  • cannot open eclipse app on windows after reinstall, shows workspace error

    cannot open eclipse app on windows after reinstall, shows workspace error

     

    i just installed a new version of eclipse and when I set my workspace to my normal one it just says : default workspace … is in use or cannot be created. I restarted pc and even deleted the .lock file in the .metadata. Anything else that could be wrong?

  • Can Eclipse line wrap large strings

    Can Eclipse line wrap large strings?

    I’m pretty new to Eclipse. I’m trying to format my code so that it fits within 100 columns max. I tried doing this in eclipse by making my own Eclipse Java Formatting profile. However one thing this doesn’t do is separate large strings into multiple smaller strings with + signs.

  • Running Maven commands on the command line in Eclipse

    Running Maven commands on the command line in Eclipse

     

    I am trying to use Maven to export my project into a JAR file, however I am also trying to export the dependencies as well and I am using the shade plugin, however I am wondering how exactly would I then run it? I read I need to run “mvn shade:shade”, however I don’t exactly know where I run this? in the terminal I get ‘mvn’ is not recognized as an internal or external command, operable program or batch file. So I don’t really know where I am supposed to run this

    ——

    Note: This solution assumes that your project is configured/imported as a Maven project.

    Right-click the project in Eclipse. Select Run as > Maven build… > Goals, type package and then click Run.

    Following best practices, you should not run shade:shade from the CLI (which you are actually doing with this approach), but rather bind the shade plugin to the package phase.

    This link will explain how to do that, if you haven’t already done it.

     

  • How to pack mysql connector with src folder in java

    How to pack mysql connector with src folder in java?

    I have a Java Project with multiple source folders inside it . I want to pack ONLY one of the source folder as a jar to use in other java project. But along with the packaging I want to pack mysql connector jar file also along with the packaging of source folder . And I am not using maven only simple Java Project.

  • Why does the Eclipse debugger open up random classes when debugging

    Why does the Eclipse debugger open up random classes when debugging?

    I’m new to Java and use Eclipse.

    When using the debugger’s step into button, it will sometimes open up a new class with loads of code and comments. It will then start stepping through a few lines of the new class it opened and then jump back to my class.

    Sometimes it opens up more than one class and takes 20 steps to jump back to my code.

    Can someone give me a simplified explanation why this happens and what the new class it opened is for?

    ——

    Step into – An action to take in the debugger. If the line does not contain a function it behaves the same as “step over” but if it does the debugger will enter the called function and continue line-by-line debugging there.

    Step over – An action to take in the debugger that will step over a given line. If the line contains a function the function will be executed and the result returned without debugging each line.

    So what is happening in your case is debugger is going through function’s implementation from the framework or library that you used, which is invoked in your code.

    As mentioned in the comments used step over instead of step into, so the debugger will not go through those framework or library source code.

  • Access Sub-Jars of Jar with Eclipse

     

    I have a maven project and exported it as a single jar using Eclipse’s export to jar option. I created a new project and imported the jar by adding it to the classpath (add external jar). The jar seems to contain all sub dependencies:

    Now, I want to use a class of such as subdependencie, e.g. form the commons package. However, I can not import it. How do I do that?

  • How to connect eclipse to my local dev enviornment?

    How to connect eclipse to my local dev enviornment?

  • Remotely Debugging an Eclipse Plugin

    This tutorial will show you how to debug an Eclipse plugin remotely for bug resolution after it has been installed in the IDE.

    Introduction
    The Eclipse plugin can be debugged from inside the IDE while in the development phase, but once the plugin is installed in the IDE, we need to debug it remotely for bug resolution. In this quick tutorial, I’m going to explain how to debug an Eclipse plugin remotely.

    Plugin Project
    Let’s suppose we have developed our simple Hello World plugin and installed it in our IDE. Now, to debug the plugin remotely, please follow the steps below.

    Step 1
    Open the first instance of Eclipse IDE pointing to the workspace where your Hello World plugin project is located.

    Step 2
    Navigate to the eclipse.ini file of your IDE. Here is a screenshot of the location of the file in MacOS.

    Image title

    Now add the following JVM arguments to the file:

    -vmargs
    -Xdebug
    -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
    Step 3
    Now, open another instance of the Eclipse IDE (on MacOS, use the command open -a -n Eclipse in the terminal).This instance will point to a workspace different from the one which contains the Hello World plugin project.

    Step 4
    Now, in the workspace containing the Hello World plugin project, make the following remote debug configurations/; Navigate Run -> Debug Configurations -> Remote Java Application.

    Image title

    Then hit the debug button. Also, do not forget to put break-points in the codes of the Hello World plugin to be debugged.

    Step 5
    In the other workspace (which does not contain the Hello World plugin) try to use the Hello World plugin and it will be remotely debugged in the other instance of Eclipse.

    Conclusion
    In this brief tutorial, I have shown how to debug an Eclipse plugin remotely.

  • Eclipse 格式化代码时不换行与自动换行的实现方法

    1. preferences->Java->Code Style->Code Formatter->Show… ,打开之后,选择“Line Wrapping”选项卡,在“Maximun line width”指定大于多少列时换行。
    2. 还是在“Line Wrapping”选项卡中,能过选择”Line Wrapping policy”可以指定构造函数、方法体等的换行情况。 不过,SUN推荐的编码风格默认是80列换行。
    Java代码

    打开Eclipse的Window菜单,然后Preferences->Java->Code Style->Formatter->Edit/Show(根据不同版本可用的按钮会不一样) ->Line Wrapping->Maximum line width:由80改成800就行了。

    Html代码

    Window->Preferences->MyEclipse->Files and Editors->Html->Html Source->Line width->加个0以后保存。