• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:08
CEST 00:08
KST 07:08
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro8 Preview Pt2: Progenitors2Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22
Community News
RSL Revival: Season 5 - Qualifiers and Main Event10Code S Season 1 (2026) - RO12 Results02026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15
StarCraft 2
General
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Code S Season 1 (2026) - RO12 Results Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid
Tourneys
RSL Revival: Season 5 - Qualifiers and Main Event GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
[ASL21] Ro8 Preview Pt2: Progenitors Why there arent any 256x256 pro maps? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion
Tourneys
[ASL21] Ro8 Day 2 [Megathread] Daily Proleagues Escore Tournament StarCraft Season 2 [BSL22] RO16 Group Stage - 02 - 10 May
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread Daigo vs Menard Best of 10 Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Movie Stars In Video Games: …
TrAiDoS
ramps on octagon
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1837 users

The Big Programming Thread - Page 599

Forum Index > General Forum
Post a Reply
Prev 1 597 598 599 600 601 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 18:58:17
March 03 2015 18:45 GMT
#11961
QUICK UPDATE

i changed the 2 things to look a bit more like the old example.... they look like this now and i'm just getting an error "non-static variable service cannot be referenced from a static context" which means something like i need to format it to be outside my Main but i want my Main to run it or it says my file has no Main and wont run it ... o.o

main-ish class
+ Show Spoiler +


package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

getservice service;

public static void main(String[] args) {

try {

// @Inject


// Ann ann = new Ann();


String output = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);

} catch (Exception e) {

e.printStackTrace();

}
}
}


getservice class
+ Show Spoiler +

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);
}

}



basically i have to move the line "String output = service.fetchMovie().getAnime().getName();" so its not in the Main method ...? so what do i put in a Main method to make it go?
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Cyx.
Profile Joined November 2010
Canada806 Posts
March 03 2015 19:10 GMT
#11962
On March 04 2015 03:45 FFGenerations wrote:
QUICK UPDATE

i changed the 2 things to look a bit more like the old example.... they look like this now and i'm just getting an error "non-static variable service cannot be referenced from a static context" which means something like i need to format it to be outside my Main but i want my Main to run it or it says my file has no Main and wont run it ... o.o

main-ish class
+ Show Spoiler +


package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

getservice service;

public static void main(String[] args) {

try {

// @Inject


// Ann ann = new Ann();


String output = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);

} catch (Exception e) {

e.printStackTrace();

}
}
}


getservice class
+ Show Spoiler +

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);
}

}



basically i have to move the line "String output = service.fetchMovie().getAnime().getName();" so its not in the Main method ...? so what do i put in a Main method to make it go?

Would something like
public static void main(String [] args) {
...
JavaApplication4 app = new JavaApplication4();
String output = app.service.fetchMovie().getAnime().getName();
...
}

work for you?
zzdd
Profile Joined December 2010
United States484 Posts
March 03 2015 19:12 GMT
#11963
On March 04 2015 03:45 FFGenerations wrote:
QUICK UPDATE

i changed the 2 things to look a bit more like the old example.... they look like this now and i'm just getting an error "non-static variable service cannot be referenced from a static context" which means something like i need to format it to be outside my Main but i want my Main to run it or it says my file has no Main and wont run it ... o.o

main-ish class
+ Show Spoiler +


package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

getservice service;

public static void main(String[] args) {

try {

// @Inject


// Ann ann = new Ann();


String output = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);

} catch (Exception e) {

e.printStackTrace();

}
}
}


getservice class
+ Show Spoiler +

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);
}

}



basically i have to move the line "String output = service.fetchMovie().getAnime().getName();" so its not in the Main method ...? so what do i put in a Main method to make it go?

public static void main(String[] args) {
getservice service = new getservice();
String output = service.fetchMovie().getAnime().getName();
}

Try something like this.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 19:28:29
March 03 2015 19:16 GMT
#11964
woah woah thats what i just changed it to XD from googling the problem
+ Show Spoiler +

package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

//getservice gt;

public static void main(String[] args) {


getservice gt = new getservice();

String output = gt.fetchMovie().getAnime().getName();


//Ann = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);


}
}


result (it ran)
+ Show Spoiler +

Exception in thread "main" java.lang.NullPointerException
at javaapplication4.getservice.fetchMovie(getservice.java:36)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


well done guys ill look at this next bit







ok the next bit is that client and target remain null when they should be set during protected void init() {
+ Show Spoiler +


/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);


}

}



i wonder if i need to activate them somehow , as if getservice gt = new getservice(); isnt enough to do so..
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 03 2015 19:33 GMT
#11965
some pretty god like stuff about entity based systems

http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/
The harder it becomes, the more you should focus on the basics.
zzdd
Profile Joined December 2010
United States484 Posts
Last Edited: 2015-03-03 19:40:12
March 03 2015 19:40 GMT
#11966
On March 04 2015 04:16 FFGenerations wrote:
woah woah thats what i just changed it to XD from googling the problem
+ Show Spoiler +

package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

//getservice gt;

public static void main(String[] args) {


getservice gt = new getservice();

String output = gt.fetchMovie().getAnime().getName();


//Ann = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);


}
}


result (it ran)
+ Show Spoiler +

Exception in thread "main" java.lang.NullPointerException
at javaapplication4.getservice.fetchMovie(getservice.java:36)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


well done guys ill look at this next bit







ok the next bit is that client and target remain null when they should be set during protected void init() {
+ Show Spoiler +


/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);


}

}



i wonder if i need to activate them somehow , as if getservice gt = new getservice(); isnt enough to do so..

I think you have to enable @PostConstruct.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 21:00:10
March 03 2015 19:57 GMT
#11967
On March 04 2015 04:40 zzdd wrote:
Show nested quote +
On March 04 2015 04:16 FFGenerations wrote:
woah woah thats what i just changed it to XD from googling the problem
+ Show Spoiler +

package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

//getservice gt;

public static void main(String[] args) {


getservice gt = new getservice();

String output = gt.fetchMovie().getAnime().getName();


//Ann = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);


}
}


result (it ran)
+ Show Spoiler +

Exception in thread "main" java.lang.NullPointerException
at javaapplication4.getservice.fetchMovie(getservice.java:36)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


well done guys ill look at this next bit







ok the next bit is that client and target remain null when they should be set during protected void init() {
+ Show Spoiler +


/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);


}

}



i wonder if i need to activate them somehow , as if getservice gt = new getservice(); isnt enough to do so..

I think you have to enable @PostConstruct.


yeah i deleted half of those @annotations coz fuck knows what they are and everyone does it differently and the example i started with does it in a specific way to output in a different way??.>....., now im trying to figure out what to put back or how to fix it lol. thanks (will update)

yeah right now i'm trying to put @Inject somewhere : this is permitted but it doesnt change anything (and it looks pretty shitty) + Show Spoiler +
public class JavaApplication4 {

@Inject
getservice gt;

public static void main(String[] args) {

getservice gt = new getservice();



maybe i need to configure the project or make one of the files a servlet or bean or something like that? i made the project "web application" then just made plain java classes....

when i rigthclick->properties the old example project it has things like "run on glassfish server" in the properties ......my project has none of that or even the options...

no i remade it as web application and made one of them a bean or something and it didnt do much lol

i reposted to stackoverflow here if you want to re-read but with better formatting sort of

http://stackoverflow.com/questions/28841666/jax-rs-postconstruct-inject-tag-in-simple-get-request-project
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 03 2015 21:23 GMT
#11968
This seems so unnecessarily complicated...
There is no one like you in the universe.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 21:37:08
March 03 2015 21:32 GMT
#11969
what do you mean? it is like 20 lines of code (see the stackoverflow link) ...im just trying to see if it stores the data as an object ... i should probably go and start from scratch again so i can start to understand this annotation stuff but the thing im trying to see work right now is if it stores the xml into an object....just it looks like the connection part has died when i started calling the service as an instance.... maybe something like this http://stackoverflow.com/questions/18161682/why-is-postconstruct-not-called
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
zzdd
Profile Joined December 2010
United States484 Posts
March 03 2015 21:36 GMT
#11970
On March 04 2015 04:57 FFGenerations wrote:
Show nested quote +
On March 04 2015 04:40 zzdd wrote:
On March 04 2015 04:16 FFGenerations wrote:
woah woah thats what i just changed it to XD from googling the problem
+ Show Spoiler +

package javaapplication4;

import generated.Ann;
import javax.inject.Inject;

public class JavaApplication4 {

//getservice gt;

public static void main(String[] args) {


getservice gt = new getservice();

String output = gt.fetchMovie().getAnime().getName();


//Ann = service.fetchMovie().getAnime().getName();
// error is above is "non-static variable service cannot be referenced from a static context"

System.out.println(output);
// String output = fetchMovie(Ann ann).getName();
// System.out.println(output);


}
}


result (it ran)
+ Show Spoiler +

Exception in thread "main" java.lang.NullPointerException
at javaapplication4.getservice.fetchMovie(getservice.java:36)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


well done guys ill look at this next bit







ok the next bit is that client and target remain null when they should be set during protected void init() {
+ Show Spoiler +


/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import generated.Ann;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

/**
*
* @author J
*/

@ApplicationScoped
public class getservice {

private Client client;
private WebTarget target;

@PostConstruct
protected void init() {
client = ClientBuilder.newClient();
//target = client.target("http://www.omdbapi.com");
target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml");
}

public Ann fetchMovie() {
//return target.queryParam("anime", "4658")
return target.queryParam("anime", "4658")
.request(MediaType.TEXT_HTML)
.header("Content-type", "text/html")//application_json or text_html or xml
.get(Ann.class);


}

}



i wonder if i need to activate them somehow , as if getservice gt = new getservice(); isnt enough to do so..

I think you have to enable @PostConstruct.


yeah i deleted half of those @annotations coz fuck knows what they are and everyone does it differently and the example i started with does it in a specific way to output in a different way??.>....., now im trying to figure out what to put back or how to fix it lol. thanks (will update)

yeah right now i'm trying to put @Inject somewhere : this is permitted but it doesnt change anything (and it looks pretty shitty) + Show Spoiler +
public class JavaApplication4 {

@Inject
getservice gt;

public static void main(String[] args) {

getservice gt = new getservice();



maybe i need to configure the project or make one of the files a servlet or bean or something like that? i made the project "web application" then just made plain java classes....

when i rigthclick->properties the old example project it has things like "run on glassfish server" in the properties ......my project has none of that or even the options...

no i remade it as web application and made one of them a bean or something and it didnt do much lol

i reposted to stackoverflow here if you want to re-read but with better formatting sort of

http://stackoverflow.com/questions/28841666/jax-rs-postconstruct-inject-tag-in-simple-get-request-project

The laziest solution would be to call the init method from your gt object.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-03 21:49:59
March 03 2015 21:38 GMT
#11971
oh god well done it worked

do you have a brief on what was wrong or should i just forget about it and go learn the annotations/jaxrs stuff and forget about it? (i did try to put the @Inject thing here and there but it didnt help)

look a celebratory picture

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
zzdd
Profile Joined December 2010
United States484 Posts
March 03 2015 22:21 GMT
#11972
On March 04 2015 06:38 FFGenerations wrote:
+ Show Spoiler +
oh god well done it worked

do you have a brief on what was wrong or should i just forget about it and go learn the annotations/jaxrs stuff and forget about it? (i did try to put the @Inject thing here and there but it didnt help)

look a celebratory picture

[image loading]

I'm not that familiar with @PostConstruct but it seems like it would normally be called after you inject. Since you aren't doing that, the init method is not being called.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
March 04 2015 01:12 GMT
#11973
On March 04 2015 07:21 zzdd wrote:
Show nested quote +
On March 04 2015 06:38 FFGenerations wrote:
+ Show Spoiler +
oh god well done it worked

do you have a brief on what was wrong or should i just forget about it and go learn the annotations/jaxrs stuff and forget about it? (i did try to put the @Inject thing here and there but it didnt help)

look a celebratory picture

[image loading]

I'm not that familiar with @PostConstruct but it seems like it would normally be called after you inject. Since you aren't doing that, the init method is not being called.


well i will endeavour to understand it and report back here some time XD
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
berated-
Profile Blog Joined February 2007
United States1134 Posts
March 04 2015 02:32 GMT
#11974
On March 04 2015 10:12 FFGenerations wrote:
Show nested quote +
On March 04 2015 07:21 zzdd wrote:
On March 04 2015 06:38 FFGenerations wrote:
+ Show Spoiler +
oh god well done it worked

do you have a brief on what was wrong or should i just forget about it and go learn the annotations/jaxrs stuff and forget about it? (i did try to put the @Inject thing here and there but it didnt help)

look a celebratory picture

[image loading]

I'm not that familiar with @PostConstruct but it seems like it would normally be called after you inject. Since you aren't doing that, the init method is not being called.


well i will endeavour to understand it and report back here some time XD


Oh my...

Read through your posts, you are.. on quite the journey. Java EE doesn't feel like its something that you can just kinda bs your way through. All the annotations you are trying to use are a part of CDI, its the EE way of doing spring and ultimately using Inversion of Control pattenr. You can read up on it if you wish, but, you aren't going to have a full CDI container when you just try to hook up a main method. Nothing has told the application to even try to start doing CDI, let alone initialize all the beans.

http://docs.oracle.com/javaee/6/tutorial/doc/giwhl.html
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-03-04 03:39:37
March 04 2015 03:36 GMT
#11975
lol , there's no way i can understand that sort of documentation :D

i'm not trying to BS my way, i just need to show my tutor that i'm starting to accomplish something on my personal project and telling him "oh i done a java tutorial and sort of understand bits of it a bit more" for the 20th week running won't go down well. the problem with that is there's no tutorials that do "exactly" the things i want to do so its sort of trying to mesh random shit together without having any idea if it will work let alone how to troubleshoot it

anyway this little prototype is working so i can show him i've bothered , and now i'll switch back to something there's an actual tutorial for (basic ecommerce or rest application)

cheers :D
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
March 04 2015 05:32 GMT
#11976
On March 04 2015 12:36 FFGenerations wrote:
lol , there's no way i can understand that sort of documentation :D

i'm not trying to BS my way, i just need to show my tutor that i'm starting to accomplish something on my personal project and telling him "oh i done a java tutorial and sort of understand bits of it a bit more" for the 20th week running won't go down well. the problem with that is there's no tutorials that do "exactly" the things i want to do so its sort of trying to mesh random shit together without having any idea if it will work let alone how to troubleshoot it

anyway this little prototype is working so i can show him i've bothered , and now i'll switch back to something there's an actual tutorial for (basic ecommerce or rest application)

cheers :D


http://www.objc.io/issue-11/dependency-injection-in-java.html
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-03-04 09:03:06
March 04 2015 09:02 GMT
#11977
On March 04 2015 12:36 FFGenerations wrote:
lol , there's no way i can understand that sort of documentation :D

i'm not trying to BS my way, i just need to show my tutor that i'm starting to accomplish something on my personal project and telling him "oh i done a java tutorial and sort of understand bits of it a bit more" for the 20th week running won't go down well. the problem with that is there's no tutorials that do "exactly" the things i want to do so its sort of trying to mesh random shit together without having any idea if it will work let alone how to troubleshoot it

anyway this little prototype is working so i can show him i've bothered , and now i'll switch back to something there's an actual tutorial for (basic ecommerce or rest application)

cheers :D


Unfortunately the number of times that there is a tutorial that shows you exactly what to do goes down very, very quickly. Trying to read that type of documentation and then figuring out how to piece together what you've read and actually applying it plays a large part of ones ability to solve problems. All that aside, I know that the ramp up time on this stuff isn't quick... there is a ton of shit to try to wrap your head around.

CDI Annotations are quite powerful, but, as you found with your main method if you aren't running inside a container they are quite useless. You need to make sure that you have a reason for using one of the annotations, don't just use them because you can.

Your getservice class (which should follow proper java class naming conventions -- GetService) will still work even without a @PostConstruct. @PostConstruct is going to work best when you have a service that has dependencies injected (@Inject) and then the service needs to do something afterwards to continue with initialization. A quick glance at your class doesn't reveal any dependencies, so changing your init() method to a constructor will allow for you to use your GetService even in a main method.
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
March 04 2015 09:22 GMT
#11978
On March 03 2015 21:30 sabas123 wrote:
Show nested quote +
On March 03 2015 08:11 netherh wrote:
On March 03 2015 04:15 sabas123 wrote:
I recently saw a few posts on gamedev about entity based architecture in c++.

I was wondering how I could make a custom component and then attach it to my entity. I would assume that the base enitity would just be a long int

ref: http://gamedev.stackexchange.com/questions/31473/role-of-systems-in-entity-systems-architecture/31491#31491



template<class T, class... Args>
T* AddComponent(Args&&... args)
{
// create component
// add to vector

// if object is connected
connect this component

// return component
}



this would be something like?

template<class T, class... Args>
T* AddComponent(Args&&... args)
{
FooComponent.connect(this);
components.push_back(FooComponent);
connect();
}

where <class T, class args> would be the class I want to add and the argument so of the constructor of that class?


For me it looks like this:



template<class T, class... Args>
T* AddComponent(Args&&... args)
{
auto c = std::make_unique<T>(std::forward<Args>(args)...);

components.emplace_back(std::move(c));

if (connected)
components.back().Connect(*this);

return components.back().Cast<T>();
}


Yep, T is the component type, and Args is the argument list for the component constructor. I'm actually using a type hiding class, hence the Cast call at the end. It's just the result of using unique_ptr: You have to move the unique_ptr into the vector, then you lose the original type and have to cast to get the correct return value.

If you're using unique_ptr<Component> directly in the entity class, I guess you'd have to get the raw pointer and dynamic_cast (or static_cast if you know certain conditions are always fulfilled).

This becomes much simpler if you just store raw pointers since there's no moving, but you have to be careful to delete things properly.

With C++03, you have to new the component outside the class anyway, since you can't forward arguments to a constructor.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 04 2015 18:54 GMT
#11979
what is wrong with comparing strings with == or != ?
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2015-03-04 19:18:37
March 04 2015 19:15 GMT
#11980
On March 05 2015 03:54 travis wrote:
what is wrong with comparing strings with == or != ?


A String variable is effectively a pointer to memory where the characters that make up the string are located. By comparing Strings using == and !=, you're comparing the pointers.

In C, C++, and C#, this won't work 80% of the time, as the same string may be located at different memory locations. It will work on the occasion that you do:

typedef string char[];
string a = "foo";
string b = a;


In Java, Strings are immutable types. The Java interpreter knows of a special property with immutable types that it can use the same memory for identical Objects, so using the == and != in Java works since both String Objects point to the same place in memory.... sometimes. It's undefined how often or when it will work, since there are optimizations that depend on the length of the string, total number of Objects, memory used, generation in the garbage collection, etc.

In Python, the immutable types optimization comes up again, with the added difficulty of type coercion. Using "is" instead of "==" will result in the Strings actually being compared, where using "==" will check that they both point to the same String. If one does not point to a String, you may get NaN instead of True or False... !Fun!

In Javascript, "==" will coerce types causing certain corner cases to give odd results, such as NaN instead of False."===" will probably do the string equality you want instead.
Any sufficiently advanced technology is indistinguishable from magic
Prev 1 597 598 599 600 601 1032 Next
Please log in or register to reply.
Live Events Refresh
IPSL
19:00
Ro24 Group F
eOnzErG vs TBD
G5 vs Nesh
Airneanach28
Liquipedia
BSL
19:00
RO16 Group B
Bonyth vs Sterling
KwarK vs JDConan
ZZZero.O289
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SpeCial 217
JuggernautJason103
StarCraft: Brood War
ZZZero.O 289
Artosis 149
NaDa 16
KwarK 8
Dota 2
monkeys_forever536
League of Legends
Doublelift3212
Super Smash Bros
C9.Mang0300
hungrybox0
Heroes of the Storm
Liquid`Hasu427
Other Games
gofns13044
tarik_tv9696
summit1g5854
Grubby5529
FrodaN1376
Liquid`RaSZi1191
Dewaltoss41
UpATreeSC37
NightEnD19
Organizations
Other Games
gamesdonequick1676
Dota 2
PGL Dota 2 - Main Stream47
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• musti20045 21
• Adnapsc2 16
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• imaqtpie1237
• Shiphtur353
Upcoming Events
Patches Events
1h 52m
Replay Cast
10h 52m
Wardi Open
11h 52m
Afreeca Starleague
11h 52m
Jaedong vs Light
Monday Night Weeklies
17h 52m
Replay Cast
1d 1h
Sparkling Tuna Cup
1d 11h
Afreeca Starleague
1d 11h
Snow vs Flash
WardiTV Invitational
1d 12h
SHIN vs Nicoract
Solar vs Nice
GSL
2 days
Classic vs Cure
Maru vs Rogue
[ Show More ]
GSL
3 days
SHIN vs Zoun
ByuN vs herO
OSC
3 days
OSC
3 days
Replay Cast
4 days
Escore
4 days
The PondCast
4 days
WardiTV Invitational
4 days
Zoun vs Ryung
Lambo vs ShoWTimE
Replay Cast
5 days
CranKy Ducklings
5 days
RSL Revival
5 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
5 days
Krystianer vs TriGGeR
Cure vs Rogue
BSL
5 days
Replay Cast
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
6 days
BSL
6 days
Liquipedia Results

Completed

Proleague 2026-05-02
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
KK 2v2 League Season 1
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.