I have two Java IDEs that I alternate between. jGRASP is for simpler tests and miscellaneous files, and Netbeans I use for more complex projects.
I'm currently using jGRASP and I'm trying to declare a JComboBox<String> object, but when I try to compile it, it gives me the message:
type javax.swing.JComboBox does not take parameters
But when I use JComboBox in Netbeans and set its parameter type to String, it doesn't give me that error. Does anyone know why this is?
Support for generics was only added to JComboBox in Java 1.7. Your jGRASP IDE is probably using an earlier version of Java
You can turn on "Settings" > "Verbose Messages" in jGRASP to see which "javac" is being called during compilation. Look for the "actual command sent" line in the output.
On Windows, jGRASP will look for the newest version of Java when it starts and use that to run itself and run/compile your programs. If the Java part of the registry is futzed up, this may fail. You can use "Settings" > "jGRASP Startup Settings" to manually select a Java installation. If you do that, just remember to change it when you upgrade Java (probably just change it back to [default]).
Related
I am newbie to plugins in vim. I am using vim for a year but without any experience with plugins. So i installed Vim-plug, then add Plug vim-javacomplete2' to my .vimrc and :PlugInstall it. It was installed. Then I add autocmd FileType java setlocal omnifunc=javacomplete#Complete to my .vimrc as well - as is in github. But then, ther is nothing else. So some commands works. I Tried for example JCgenerateAccessors - which generate getter and setter upon my private fields. So commands works. But The autocompletation doesn (such main function). I am making classes within a file in my directory. Then javac Test.java and java Test - which runs it. But still, when editting in vim the Test.java, no autocompletation. What I did wrong?
Might a a bit late
<C-x><C-o> (ctrl + x,ctrl + o) will bring up a list of options.
Press this in insert mode wherever you would press ctrl + space in other IDEs
i.e.: after System.
Expanding upon #iaquobe's answer, autocompletion while typing or more specifically after the dot notation, isn't enabled by default with this plugin, unless triggered manually using C-x,C-o, which can -and will- become tedious over time.
There're other autocompletion plugins that can be installed along with other completion engines, and be configured to integrate with them, namely: vim-mucomplet, youcompleteme, and neocomplete.vim.
I am a beginning programmer that has been using an IDE to learn to code. However I want to try using a text editor to see which one I would like more. My question is, once you download a text editor, what tools do you need to compile and run a program and how do you set them up?
You just need the JDK. Installing it (it has an installer) should set it up sufficiently.
When you want to compile something, use the javac tool:
> javac MyClass.java
When you want to run something, most likely you'll want the java tool (although of course if you're doing servlets or such, you'd use something else):
> java MyClass
Or of course, go ahead and use a separate text editor if you like but continue to use the IDE to compile, not least because presumably any IDE you were using had an integrated debugger, and a debugger is an essential tool.
If you want to use a text editor for java programming don't forget to add java to your Environment Variables Path. You can check if java is already added to your path by running java -version in your command line. If you get nothing you have to add C:\Program Files\Java\jdk1.8.0; to your path (your version of the jdk may be different, change it to the name you have). Don’t forget that semi-colon ; at the end.
Now you are set and ready to compile and run java programs just as explained by #T.J. Crowder in the answer above.
I'm using Mac for the first time and I'm assuming this is a OS specific error, because the same code worked well on Ubuntu.
I'm trying to compile this code and Eclipse is showing me a lot of errors like this one:
Access restriction: The method invokeLater(Runnable) from the type
SwingUtilities is not accessible due to restriction on required
library
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/rt.jar
This is the first time I facing something like this and I don't know how to continue.
I'm using Java 8.
I honestly have no clue why this happens, and it's a pain when I can't remember how I fixed it last time. Some Eclipse quirk, I suppose.
I usually fix this by removing the JRE System Library from the build path and then adding it back.
I guess is that Mac does not support System Trays. You should check if support exists using the method java.awt.SystemTray.isSupported(). Does this return true?
EDIT: I guess the problem is more at the Eclipse IDE level? Try reinstalling Java.
I wrote a project in eclipse with an older version of java.
Now on a different computer but running the same codes I'm getting a whole lot of red.
This is due to Version incompatibility.
I've had my professor change the Java version from within the console window before. The code compiled just fine after he did so. I'm sure its the same case with this code.
After looking at other tutorials and google links I could only find command line approaches and #override methods. To be honest I still don't understand these.
What is the best way to change the version of a code originally written in an older code inside the eclipse console?
thanks!
In eclipse go to Window -> Preferences -> Java -> Compiler, there you can change the java versions. Hope it helps.
Ideally if we want to have two different versions of Java [say 1.6 and 1.7], then we should have two workspace defined accordingly to avoid any mixup. We can also change the Project Facets if our projects has facets that is.
In Eclipse Follow steps given below:
1) Windows -> Preferences -> Java -> Compiler and as per the image set the compliance compiler level as per your requirements.
2) Windows -> Preferences -> Java -> Installed JRE's and check if your required jre/jdk is available or not as given in image below:
3) Right Click on Your Project and go to Java Build Path and check if your required Library is available or not as per image given below:
4) Now you can edit the JRE System Library or add one by clicking on button's available on last image's right side, then a pop up as given below will open up. Here, you can change the execution environment [default values also can be set]
In myeclipse select the project -> properties -> java compiler -> there you can specify jdk version.
Easy
Download the jdk from Oracle's official website for the version you want to compile your project with.
JDK Oracle's official
create a new Java project
[
Once the project has been generated, If you select the part that says Configure JREs
By default eclipse will use the version you have installed on your system so if you don't change this configuration you will never be able to run the program with the build you need, in this case I will use jdk 1.8.
After pressing Add
5.1 And choose the option select the 3rd option in this case, called Standard VM and press Next
Now eclipse asks us to indicate the path where the libraries and other content is located in order to compile and run the program, we only have to indicate the directory where it is located.
As my goal is to run a program with the JRE 8 , I will look for the directory path where the download described in option 1 of this message is located.
As a quick example, since I just want my program to compile without worrying about anything else, I will add all the contents of my address.
Now we change by clicking on the JRE we want to compile our program, to be changed to the original default so that the new selection is executed ; and finally we press Apply and Close and Next
Press Finish to create the project
Now we have the whole project with all the necessary content to compile and run it.
Personally I think this is the quickest and cleanest way to do it ; the problem I encountered when I changed JDK is that when compiling I couldn't find the directory with the necessary components to run it, you had to download it and configure it together with the default parameters, which can cause a lot of headaches for less experienced users.
Finally, this is the version of eclipse that I am using
I hope you find this system useful, I use it to be able to run old examples that use applets , which are obsolete classes and jvm does not compile.
I'm stuck with Eclipse in one project and I would like to have autocompletion similar to that of IntelliJ - two major problems are:
Start typing and Eclipse would automatically suggest all possibilities
When there is item selected in dropdown list you can accept it not only with enter key but with dots, spacebars...
Go to Window → Preferences → Java → Editor → Content Assist.
In the column "Auto activation triggers for Java", enter this:
.qwertyuioplkjhgfdsazxcvbnm_QWERTYUIOPLKJHGFDSAZXCVBNM
Add any other keys you want. You're done. That answers your first query.
As far as second one goes, I think it already exists.
Take a look at Eclipse Code Recommenders [1] or Codetrails Connect [2]. They make Eclipse' code completion intelligent.
[1] http://eclipse.org/recommenders/
[2] http://marketplace.eclipse.org/content/codetrails-connect-community-edition/
I have to say NO. I moved from Eclipse to IntelliJ because of the intellisense and inability to make Eclipse behave like IntelliJ (or if you come from the .NET environment: inability to make Eclipse intellisense behave like ReSharper in .NET).
Do you HAVE TO work in Eclipse? I do 98% of work in IntelliJ, then convert the project into Eclipse project (IntelliJ can still access it) and finish it in Eclipse. Maybe you could try this solution.
Since Eclipse Juno, Code Recommenders Intelligent Java Proposals replaced the old JDT's Java Proposals.
It afford "Intelligent Code Completion" function, like IntelliJ did in a way.
You can get something useful through the link below:
http://code-recommenders.blogspot.jp/2012/07/code-recommenders-10-code-completion-on.html
There is something like that in Eclipse I think, certainly in the Eclipse Helios. When typing you press CTRL+SPACE, or when you typed variable name '.' will start auto-complete options.
Also here someone suggests to change auto complete delay settings to 0.
BTW you can also accept your selection with space bar, for sure.
EDIT:
Why not consider using NetBeans, my personal favourite. There you have an option to show auto-completion on start typing any Java Identifier Part. This would then look exactly as you want it. (in NetBeans Tools->Options->Editor->Code Completion, there in Language box select Java and finally check Auto Popup on Typing Any Java Identifier Part).