I need to change the package to Eclipse.
Now my package looks like this:
test
java
helloword
But I want to change it on it:
java
helloword
How can I do that?
This is quite simple:
Select the package you want to change
Press F2
Enter the new package name
Select the package you want to rename.
Select Refactor.
Click on rename
Type new name.
There u go...
Related
Whenever you display a stack trace, you can get a "url-like" text which if you click it opens the appropriate class at the appropriate line.
Is there a possibility to output a text in a way that the console recognizes it and make it clickable like that?
But how would you format the output so it would recognize it as a "link" ?
You can't and you don't.
AndroidStudio supports that feature. You just need to call
exception.printStackTrace() and you should be able to click it in the console tab of IDE.
You will see something like
java.lang.Exception
at whatever.Test.main(Test.java:22)
The text inside the bracket will be highlighted and you can click it.
Based on #JEeemy's answer I managed to do this
public static void printLinkToThisLine() {
System.out.println(Thread.currentThread().getStackTrace()[3]);
}
I works for me ...
I don't know if you're using Eclipse, but the Eclipse console parses based on a pattern: FileName.java:lineNumber.
MyFile.java:3
Would link you to the 3rd line of whatever class you specified as MyFile.
You could use:
.getClass().getName()
to the the name of the file programmatically.
I am using Eclipse Luna and i am trying to run a simple text program but Eclipse gives the error:
Error: Could not find or load main class Main
I have no idea what's going on. I haven't found anything useful on Stack Overflow or Google. Here is my code:
public class Main {
public static void main(String[] args) {
System.out.println("This is a String");
}
}
Thank you.
Your code looking fine !
Do following steps to run your class
Select your project, go to Project section in menu bar then click clean.
In tool section click on enter code here Build Automatically.
Select your class right click on it and then select run.
In the menu Run, select Run Configurations....
In the dialog box that opens, on the left side, you are supposed to have an entry Java Application, and under it, there should be your class (and maybe other classes you worked on before). It may be named Main or Main__ here.
Select it. If it was erroneously named Main__, change that to Main in the Name: field.
Now look at the entry for Main Class. In the text field, it should say Main. If it says Main__ or anything else, change that to Main.
Apply and Run.
I have following code:
public class MyClass{
...
}
At same workspace I have following class
public class AnotherClass{
#Autowired
MyClass myClass;
...
}
If I click right mouse button on MyClass(first mentioned) and select "open call hierarchy" I don't see anything.
How to find this usage in Eclipse?
PC:
Select a word (class name, method name, variable name, etc.)
Press Ctrl+Shift+G
Mac:
Select a word (class name, method name, variable name, etc.)
Press Alt+Cmd+G (⌥+⌘+G)
Right click on Myclass, find references in project|workspace.
Open call hierarchy, open inheritance hierarchy.
For your case, I think both of (Ctrl +Shift+G) and (Ctrl +Alt+H) work.
To make it more clear:
(Ctrl +Shift+G) is shortkey for Search->References->workspace
Ctrl +Alt+H is short key for Call hierarchy.
Some other useful short keys like:
(Ctrl+G) : Search->Declaration->worksapce
(Alt+Left) : Back position
(Alt+Right) : Forward position
Try right-click on MyClassand then References->Workspace. I think this might be what you're looking for.
Also works on methods, variables etc.
Select the resource (method name, class name ) & right click . You will find a menu with title 'Open Call Hierarchy' (shortcut key : alt + Ctrl + H ).
This will enlist all the usage in project.
For Mac, press cmd + Shift + G
To my knowledge, both of Ctrl+Shift+G and Ctrl+Alt+H should work.
For Your Information:
Ctrl+Shift+G --> is the short key for Search --> References --> workspace
Ctrl+Alt+H --> is the short key for Call hierarchy.
How can I add my application to SendTo or Open With using Install4J?
Take a look at the Class ´WinAssociation´, there is a method
static void create( java.lang.String extension,
java.lang.String description,
java.io.File iconFile,
java.io.File executable)
// Creates a file association.
This should create a file-extension, which is opened with zur provided application.
It looks like you already got your answer on how to create an association, so here's the other answer.
The Send-To menu is actually just a directory in your user profile, called SendTo, so all you need to do it place a shortcut there. See: How to Add Items to the "Send To" Menu in Windows XP. As long as Install4J can place files wherever you ask, and you know how to create shortcuts, this should be trivial.
Currently in IntelliJ, if I right-click a package in the Project pane, I can see things such as:
new > Java class
new > File
new > Package
I want to add some new menu items in the 'new' context menu such as Interface and Enum. Does anyone know how to do this?
I've been playing around in the Settings > Menus and Toolbars without any luck.
Edit: The funny thing is if I right click a package and choose New > Edit File Templates..., I can see the template for an Interface and in the description it actually says:
This is a built-in template used by IDEA each time you create a new Java interface, by selecting New | Interface from the popup menu in one of the project views.
Unless I need to look at a different pane other than Project, I can't seem to find any context menu that lets me choose New > Interface as suggested by the above description.
New | Java Class, Create New Class dialog appears, in this dialog you can choose Kind between one of the following:
Class
Interface
Enum
Annotation
(tested with IDEA 9.0.3)
If you want Interface directly in the New list, then you have to add new template in Settings | File Templates, name it something like Java Interface and copy the contents of the Interface template into this one.
Also you can create a shortcut to save some secs.
Alt+Ctr+S -> Keymap -> in search box type 'create new' and select Java class and then assign any shortcut like Ctrl+N.
It's under the New Java Class menu.
Yes its available in Class menu : New--> Java class --> Interface .
create a package and then select create new class from that select interface and give a name.
enter image description here
then; you need to import the references files.