How to cross-reference in GoClipse? - eclipse

I have installed Eclipse (Mars) with Goclipse plugin on my Macbook yesterday. They initially work perfectly. But today I found I cannot do cross reference (that means cmd+click on a keyword cannot jump the definition). And the console shows:
Running: oracle -pos=/Users/myname/coreos/naas/server/src/mycompany.com/hh/naas-server/main.go:#389,#389
-format=json describe mycompany.com/hh/naas-server
FAILED: Could not start process:
Reason: Cannot run program "oracle": error=2, No such file or directory

As Voker suggested, GoClipse is just an Eclipse plugin. For it to compile, build, run your Go packages and applications, it requires the Go tools.
You can set the standard Go tool on the settings page:
Window -> Preferences -> Go
You can set some non-standard, differnet Go tools on the page:
Window -> Preferences -> Go -> Tools
This is where you can tell GoClipse where your oracle and gocode programs are located.
You have to download oracle yourself, but the settings page above provides you a button:
Download Go oracle (run: `go get -u golang.org/x/tools/cmd/oracle`)
So you have to go get it either manually or by the above-mentioned button. Install it using go install, so you will have the executable binary oracle. You have to set the full path of oracle on the Go -> Tools settings page, and it will work.
While we're at it: I also recommend you to install gocode (https://github.com/nsf/gocode) which will provide you the auto-complete feature (CTRL+SPACE or CMD+SPACE for a list of exported identifiers in package, list of methods etc.). Just also use the button on the same settings page:
Download gocode (run: `go get -u github.com/nsf/gocode`)
Install it and set the full path of the resulted executable binary gocode.

Related

How to make PyCharm work with the Go plugin?

I am using PyCharm 3.1.1 and I have installed the Go plugin for IntelliJ Idea. I did export GOROOT=$(go env GOROOT) to prevent PyCharm from complaining about missing GOROOT environment variable.
Now I was able to create a sample project, but the run command complains:
Error running untitled1.go: No Go Sdk defined for this project
On other sites I found that I should do something like:
Go to the File -> Project Structure and configure Go SDK by clicking + button and
selecting /usr/lib/go/ folder.
But I don't have File -> Project Structure menu item.
How to make PyCharm work with the Go plugin?
You can get most of the way there with External Tools. There is no way to replace the 'Run' button until the next version of the plug-in, per Issue #728.
To set up your external tools, go to PyCharm -> Preferences (command+,) -> Tools -> External Tools -> +
Fill in the form:
Hit OK. Use it from the menus:
Please use the latest release from Github releases https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases. It supports PyCharm 4.0.5+.
You can achieve it now with a Version 2016.1 or higher. I will give a complete guide, so the first steps would not be relevant for you. Also I write it using MacOS, so some names might be different. Go to
Preferences -> Plugins -> Browse Repositories -> Manage repositories and insert https://plugins.jetbrains.com/plugins/alpha/5047 which is the plugin behind this repo (maintained by IntelliJ). Install that plugin.
After plugin is installed, create a .go file. When you open it you will see a popup go project sdk is not defined. Click on it and select your /usr/local/go path.
A couple of helpful links:
go plugin documentation
how to set up go plugin
If you are an IntelliJ fan, you can edit and run Go using goland editor (Notice, this is not a Go plugin added to PyCharm but a different editor).
For installation on Ubontu:
sudo snap install goland --classic , or visit there website https://www.jetbrains.com/help/go/install-and-set-up-product.html
If you're running on OS X, you'll have to use the launchctl setenv command to set the GOROOT environment variable, so it's available system wide, which includes launching applications via the GUI
launchctl setenv GOROOT $(go env GOROOT)
To check it's set
launchctl getenv GOROOT
For the values to persist across reboots, you'll need to edit (or create) /etc/launchd.conf:
setenv GOROOT [path]
See this answer for more information of the format of this file. Note that you won't be able to call $(go env GOROOT) within launchd.conf

Eclipse keeps crunching while "updating rpm packages proposal list"

I've recently installed Eclipse Kepler CDT on a Win7 64 machine. It runs fine (well, sort of), but - it keeps crunching, with the status bar saying
Updating RPM packages proposal list
Why is this happening and how can I make it stop?
It's a bug in the "Linux Tools" plugin.
It seems that the plugin is unable to create the file specified at
Window -> Preferences -> Specfile Editor -> RPM Completions -> Path to packages list file
or
Window -> Preferences -> RPM -> Specfile Editor -> RPM Completions -> Path to packages list file
and therefore keeps trying to create it.
To fix this problem, just create an empty file at that location & name, or create a new empty file at a different location & name and specify it as the "Path to packages list file".
Note: You cannot create the default file (.pkglist) using Windows explorer since it won't let you create a file whose name starts with a dot. So open a console (command prompt) window and run this command:
echo. > path\to\file\.pkglist
I was able to solve this in Eclipse Kepler by going to Window -> Preferences -> Specfile Editor -> RPM Completions and un-checking Automatically build the RPM packages proposal list
Run Eclipse as administrator and it will create this fail successfully. Normal program do not have rights to write into this directory.
When developers lean to give meaningful error messages? Also, it will probably tray to write into this file sometimes in the future and that will also fail. Make this fail writable for users, normally programs run with user rights!
In Eclipse version 2022-06, the updating can be disabled by goin to Window -> Preferences -> RPM -> Specfile Editor -> RPM Completions (note the first RPM which is not present in Eclipse Kepler) and un-checking Automatically build the RPM packages proposal list
I was getting this simply because my %USERPROFILE%.pkglist didn't exist, so creating the empty file solved the problem for me.

Code completion for PHPUnit and Selenium in NetBeans

How can I get NetBeans to provide code-completion for PHPUnit classes and methods?
I have already tried downloading from the PHPUnit GitHub project, but I didn't understand why the directory is different from what's mentioned on the Selenium documentation. I am looking example for the /test/PHPUnit/Extensions/SeleniumTestCase.php file.
I have already installed PHPUnit from PEAR, but what I need now is the complete PHPUnit file so I can include it in my IDE (in this case NetBeans).
Add the PHPUnit directory to NetBeans's PHP global include path. This will provide code completion in NetBeans for all projects.
Open Tools : Options
Switch to the PHP tab
Click Add Folder... next to the Global Include Path box
Enter /usr/share/php/PHPUnit or navigate to where PEAR installed PHPUnit's source files
Click Open
Click OK
Update: The file defining PHPUnit_Extensions_SeleniumTestCase is placed in the same directory as PHPUnit when you install PHPUnit Selenium.
For example, PHPUnit_Framework_TestCase is stored in
/usr/share/php/PHPUnit/Framework/TestCase.php
The Selenium test case is stored in
/usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php
So by placing /usr/share/php/PHPUnit into the NetBeans include path, you pick up both. You have to install the extension first, of course.
pear install phpunit/PHPUnit_Selenium
Moving away from PEAR...(I'd even uninstall the PEAR version to avoid conflicts first).
Download PHPUnit with sources
https://github.com/sebastianbergmann/phpunit and extract somewhere
semi-permanent /your-install-path
Add /your-install-path/phpunit to your PATHs
In Netbeans options (Tools > Options on Windows, Netbeans > Preferences on OS X), go to PHP tab..
a. Under the General tab, Add Folder... and select the /your-install-path/src/ folder - this will make the auto complete work
b. Go to Frameworks & Tools tab, PHPUnit, select the /your-install-path/phpunit and /your-install-path/phpunit-skelgen respectively - this will make PHPUnit tool work within Netbeans
In your project settings, right click project name > Settings, Testing category, enable PHPUnit. Optionally go to the Testing > PHPUnit settings panel and make adjustments for your project.
Edit:
When I followed the instructions above, the output window told me I needed to install dependencies using "composer install." These additional steps were needed on my machine (running Netbeans 8.2 on Windows 7).
Download Composer and install: https://getcomposer.org/doc/00-intro.md
Modify your-install-path/composer.json by adding the version number between the "description" and "type" keywords like so:
"description": "The PHP Unit Testing framework.",
"version": "5.7.8",
"type": "library",
Using the command line, type the following (this is a windows machine, for mac or lunix, it should be a little different):
cd your-install-path
composer install

How to install and configure the EclipseFP Haskell plugin for Eclipse?

Can somone who has done this tell me exactly what to do? The documentation is lacking and what is there is incomplete and incorrect.
I've got the plugin installed, and told it to usethe GHC installation that I have as part of the Haskell Platform but Run As.. only shows me Run GHCi session. According to the cheat sheet, I should see Haskell Application.
Also missing are instructions for where to find the hugs executable, and the Cabal installation that the Haskell Preferences seems to suggest I should have.
Can anyone point out what I've missed?
I'm a Haskell beginner, hence trying to get Eclipse set up so I can play with it...
It seems that currently there is no way to create a non-interactive launch configuration
via GUI. However, you can do that by manually editing config files. The following instructions work with Eclipse 3.5.2, EclipseFP 2.0.2:
Make sure there exists a GHCI configuration.
Close Eclipse.
Go to directory .metadata/.plugins/org.eclipse.debug.core/launches in the root of your workspace.
There should be a file named something like "Main (project src).launch". Copy it under whatever name you wish, for instance "Run Main.launch"
Open your copied file in a text editor and replace the option --interactive with -e main.
Save the file and start eclipse. You should see the new run configuration "Run Main". When you run it, EclipseFP executes your Main.hs file, redirecting both input and output to the console view.
Also, it seems that you haven't configured cabal yet. You first need to install it (from your distribution repositories, or here if you're using Windows). Then go to Scion and Cabal preferences and point them to your cabal executable. After you click OK the compilation of Scion should start. If it gives you errors, read what packages are missing and install them via cabal install pkg-name. (I had to install happy with --global flag, and for QuickCheck I had to manually set the 2.* version). To rerun Scion compilation, restart Eclipse.

How do you install JDK?

I have eclipse and I can test run java apps but I am not sure how to compile them. I read that I should type javac -version into my cmd.exe and see if it is recognized. It is not. So I went to sun's website and downloaded/installed JDK v6. Yet it still says 'javac' is an unrecognized command. What am I doing wrong?
Thanks!
UPDATE
OK after reading some replies it seems like what I am trying to do is create a .jar file that can be ran on another computer (with the runtime). However I am having trouble figuring out how to do that. This might be because I am using Flex Builder(eclipse), but I added the ability to create java projects as well.
Thanks
UPDATE
OK I do not want to make a JAR file, I am not trying to archive it...the whole point of making a program is to send it to users so they can use the program...THAT is what I am trying to do...why is this so hard?
To setup Eclipse to use the JDK you must follow these steps.
1.Download the JDK
First you have to download the JDK from Suns site. (Make sure you download one of them that has the JDK)
2.Install JDK
Install it and it will save some files to your hard drive.
On a Windows machine this could be in c:\program files\java\jdk(version number)
3.Eclipse Preferences
Go to the Eclipse Preferences -> Java -> Installed JREs
4.Add the JDK
Click Add JRE and you only need to located the Home Directory. Click Browse... and go to where the JDK is installed on your system. The other fields will be populated for you after you locate the home directory.
5.You're done
Click Okay. If you want that JDK to be the default then put a Check Mark next to it in the Installed JRE's list.
You don't need a separate compiler, eclipse already compiles the application for you. What you probably want to do is to create an "executable" JAR file, which you can do in eclipse by selecting File->Export->Runnable JAR file.
Note, however, that the resulting JAR file is not a "real" (i.e. Windows binary) executable - it still needs a JRE installed on the target computer. There isn't really a way to create windows binaries; that's not how Java works. On the upside, it will work without recompilation on a Linux or MacOS machine (if it has a JRE installed).
javac is located in the "bin" folder of your JDK installation. In order to run it you must either use full path or add this directory to your systems search path via the Control Panel.
If you installed to c:\program files\java\jdk1.6.0 your call will have to look like this:
c:\> "c:\program files\java\jdk1.6.0\bin\javac" -version
Umm, eclipse is an IDE, it compiles things as you go. You don't need javac.
If you have Eclipse installed and you can write new java apps from within it, your compilation should work already..
Eclipse automatically builds/compiles your system when you're saving new Java files. Just try to write a new simple Hello world app, printing something to the console (just type sysout and Ctrl+Space inside Eclipse)
Eclipse automatically compiles all project in the workspace. YOu can disable this option if you like under Project->Build Automatically.
A JAR file can function as an executable, when you export your project as a JAR file in Eclipse (as Michael Borgwardt pointed out) you can specify what's the executable class, that meaning which one has the entry point [aka public static void main(String[] args)]
If the user installed the JRE he/she can double-click it and the application would be executed.
EDIT: For a detailed explanation of how this works, see the "How do I create executable Java program?"
Eclipse to use the JDK you must follow these steps.
1.Download the JDK
First you have to download the JDK from oracle site.
Download link - > https://www.oracle.com/technetwork/es/java/javasebusiness/downloads/index.html
2.Install JDK
Install it and it will save some files to your hard drive. On a Windows machine this could be in c:\program files\java\jdk(version number)
3.Eclipse Preferences
Go to the Eclipse Preferences -> Java -> Installed JREs
4.Add the JDK
Click Add JRE and you only need to located the Home Directory. Click Browse... and go to where the JDK is installed on your system. The other fields will be populated for you after you locate the home directory.
5.You're done
Click Ok. If you want that JDK to be the default then put a Check Mark next to it in the Installed JRE's list.